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

2024-06-25 23:55:25 发布

您现在位置:Python中文网/ 问答频道 /正文

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

gevent.joinall(jobs, timeout=2)

但是,joinall没有文档,但是wait方法是:

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

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


Tags: to方法文档forobjectsexample作业timeout
1条回答
网友
1楼 · 发布于 2024-06-25 23:55:25

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的功能对于greenlets来说是taylored的。在

相关问题 更多 >