Pausing and Unpausing Threads

"Martin v. Löwis" martin at
Sun Aug 12 19:18:18 CEST 2007

> I'm worried that this loop may wast some CPU cycles, and wonder if
> there's a better way through thread synchronization using such things
> as Events or Conditions.

Typically, people are after the Queue module in such cases. Each
DirectedControl(l)er would have an instance of the Queue class,
and clients would put() actions into the queue. The controller would
get() an action from the queue, execute it, get the next action,
and so on. The get() will block when the queue is empty, so you
get synchronization for free. The queue would also accommodate the
case where multiple clients want to direct the same controller
simultaneously, by, well, queuing up the tasks.


More information about the Python-list mailing list