Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我发现大多数时候当我使用 时gevent.event.Event,我的代码看起来像这样:
gevent.event.Event
old_event = self.some_event self.some_event = Event() old_event.set()
听众看起来像:
while 1: self.some_event.wait() … do stuff …
这是“正确的做法”吗?或者有没有更好的方法来通知重复事件的多个侦听器?
那么,你也可以clear()事件。
clear()
event.set() event.clear()
这将通知当前正在等待事件的侦听器,但稍后开始等待()的侦听器将被阻塞,直到下一次调用set().
set()