Pausing and Unpausing Threads

Aaron J. M. ajmacd at ns.sympatico.ca
Sun Aug 12 16:30:45 EDT 2007


On Aug 12, 3:55 pm, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
>         By this definition, if there is no "action" supplied, a
> "DirectedControler" will result in blocking ALL others (directed or not)
> in this "server" (as it blocks the entire server thread).
>
>         Is that really the behavior you want?

For my particular application, yes.  This is exactly what I want.

>         I'd suggest using a Queue PER directed controller. Initialize
>
>         self._actions = Queue.Queue()
>
> -=-=-=-=-=-
>
>         def turn(self):
>                 while True:
>                         atn = self._actions.get()       #blocks until at least one entry
>                         if atn and atn.execute():       #should be in a try/except if
>                                                                                 # action has NO execute method
>                                 break                                   #did something, so exit while
>
> -=-=-=-=-=-
>
>         def setAction(self, action):
>                 self._actions.put(action)       #could add code to ensure
>                                                                         #an execute attribute

Thank you very much for your help. :) I'll get to work on this now.

Cheers,

Aaron J. M.




More information about the Python-list mailing list