Nested greenlets

54 views
Skip to first unread message

Aarush Gupta

unread,
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

unread,
Nov 15, 2019, 7:01:10 AM11/15/19
to gev...@googlegroups.com
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
Forward
0 new messages