Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async Execution #9

Open
agucova opened this issue Sep 19, 2019 · 5 comments
Open

Async Execution #9

agucova opened this issue Sep 19, 2019 · 5 comments

Comments

@agucova
Copy link

agucova commented Sep 19, 2019

Is there any way to run two tasks simultaneously?

I'm not sure if this is an intended use case (continuous tasks).

I have a Bakefile like this:

launch/dev: launch/huey launch/flask

launch/huey:
    huey_consumer app.main

launch/flask:
    flask run

And my intention would be to run both launch/huey and launch/flask at the same time when launch/dev is called in, order to test an app.

@kennethreitz
Copy link
Owner

Use bash to do it!

@agucova
Copy link
Author

agucova commented Sep 21, 2019

But given that they are declared as separated tasks, how can I use bash to call both?

I can do this:

launch/dev:
    huey_consumer & flask run

But can bash call a task defined in the Bakefile?

@kennethreitz
Copy link
Owner

launch/dev:
    bake launch/huey & bake launch/flask

launch/huey:
    huey_consumer app.main

launch/flask:
    flask run

Make sure to use a latest release for this.

✨ 🍰 ✨

@kennethreitz kennethreitz pinned this issue Sep 23, 2019
@kennethreitz
Copy link
Owner

kennethreitz commented Sep 23, 2019

hello: hello/reuse hello/reuse/concurrent
    echo "You just ran $(red 'hello') directly, then indirectly (via bake+bash; 6 times, concurrently!)"
hello/basic:
    sleep 2
    echo "[$(red $(uuidgen))] hello!"
hello/reuse:
    bake hello/basic

hello/reuse/concurrent:
    bake hello/reuse &
    bake hello/reuse &
    bake hello/reuse &
    bake hello/reuse &
    bake hello/reuse &
    bake hello/reuse
$ bake hello
 + Executing hello/reuse:
 |  [C286C3C1-7C57-4FB1-8981-548A03BCD103] hello!
 + Executing hello/reuse/concurrent:
 |  [924F205E-11B6-43D1-8451-8FFBEE7A2536] hello!
 |  [3BDDC2E8-0329-4BC6-B8BB-D48506743E16] hello!
 |  [5C665A12-6CEF-431D-B9AE-76B217F17EA9] hello!
 |  [D71C2CB2-7C9A-4702-BD5C-EDCFCF4A9EC4] hello!
 |  [436F5009-B6AC-4C90-8E11-05E2F2BBED1C] hello!
 |  [D9BB86A7-A7A6-4ADE-8755-C21296B7AD84] hello!
 + Executing hello:
 |  You just ran hello directly, then indirectly (via bake+bash; 6 times, concurrently!)
 + Done.

@kennethreitz
Copy link
Owner

kennethreitz commented Sep 23, 2019

This works because bake automatically sets the BAKE_SILENT environment variable for the tasks that run underneath it, which is like passing the bake --silent flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants