Gevent 等待作业完成(joinall vs wait)

Gevent wait for jobs to finish (joinall vs wait)

第一个文档的 example 等待所有生成的作业完成:

gevent.joinall(jobs, timeout=2)

然而,joinall is not documented but wait方法是:

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

这两种方法是否具有相同的功能,只是在实现上有所不同?

joinall 记录在案:

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.

如您所见,功能有所不同。最大的一个是 wait 适用于很多东西,而 joinall 只适用于小绿叶。所以 joinall 的功能是为 greenlets 定制的。