Nested greenlets

Skip to first unread message

Aarush Gupta

Nov 15, 2019, 6:53:47 AM11/15/19
to gevent: coroutine-based Python network library
Has anyone ever tried Nested greenlets, if so are there any example codes I can look at?
I am looking to use gevents to execute a Depth first search kind of a model in Tree, so I would like all the children or a parent node to be executed concurrently(come as close to parallelism as possible).
Is gevents suitable for this application?

Jason Madden

Nov 15, 2019, 7:01:10 AM11/15/19
Sure, you can have greenlets create other greenlets to an arbitrary depth. That's extremely common and doesn't require anything special.

Just remember gevent doesn't help with CPU-bound processesing; your code will still only be able to use a single CPU core. If each greenlet needs to do lots of I/O, for example, you may be able to extract some concurrency that you wouldn't otherwise, but that's not a given. (Still, greenlets can be a convenient way to organize code.)
Reply all
Reply to author
0 new messages