Fork roleta

Maybe I'm missing something obvious (and it's Friday), but is there a way to make the equivalent of os.fork() on a green planet? I'm not necessarily looking to fork the process, I'm looking to take the greens and run one set of code and then another, but with independent areas (as with os.fork() ).

Any ideas or should I just sleep?

+4
source share
1 answer

To conceptually grow greens, just create another green wrapper by wrapping your "child function". I also highly recommend the gevent , which is built on the grill. The gevent code has a fork () method, but it expands the Python process and then restarts the gevent in the child. I bet you can implement everything you do in gevent with more readable code than just greenlet.

+4
source

Source: https://habr.com/ru/post/1341365/


All Articles