Pregunta

I've found that most of the time when I use gevent.event.Event, my code looks something like this:

old_event = self.some_event
self.some_event = Event()
old_event.set()

With the listeners looking something like:

while 1:
    self.some_event.wait()
    … do stuff …

Is this the “right way to do it”? Or is there a better way to notify multiple listeners of a recurring event?

¿Fue útil?

Solución

Well, you can also clear() the event.

event.set()
event.clear()

This will notify the listeners that are currently waiting for the event, but the listeners that are started to wait() later will be blocked until the next call to set().

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top