Python threading.Event() - Ensuring all waiting threads wake up on event.set()

后端 未结 4 819
有刺的猬
有刺的猬 2021-02-05 19:20

I have a number of threads which wait on an event, perform some action, then wait on the event again. Another thread will trigger the event when it\'s appropriate.

I can

4条回答
  •  鱼传尺愫
    2021-02-05 20:21

    I'm not a python programmer but if an event can only be processed once perhaps you need to switch to a message queue with the appropriate locking so that when one thread wakes up and receives the event message it will process it and remove it from the queue so its not there if other threads wake up and look in the queue.

提交回复
热议问题