Search code examples
pythongeventgreenlets

Gevent wait for jobs to finish (joinall vs wait)


The first documentation's example waits for all spawned jobs to finish with:

gevent.joinall(jobs, timeout=2)

However, joinall is not documented but wait method is:

Wait for objects to become ready or for event loop to finish.

Do both methods have the same functionality and only differ in their implementations?


Solution

  • joinall is documented:

    joinall(greenlets, timeout=None, raise_error=False, count=None) Wait for the greenlets to finish.

    Parameters:
    greenlets – A sequence (supporting len()) of greenlets to wait for. timeout (float) – If given, the maximum number of seconds to wait. Returns: A sequence of the greenlets that finished before the timeout (if any) expired.

    As you can see there are differences in functionalities. The biggest one is that wait applies to many things, whereas joinall only applies to greenlets. So the functionalities of joinall are taylored for greenlets.