Priority based concurrent execution

Doug.Fort at gmail.com Doug.Fort at gmail.com
Thu Sep 21 07:56:46 EDT 2006


Willi Richert wrote:
> Hi,
>
> I have a simulation application (PlayerStage) in which the robot is asked
> every ~200ms for an action. In the meantime the robot has to do some
> calculation with the perception. As the calculation gets more and more time
> consuming I am thinking about outsourcing it into a concurrently running
> method. If the calculation takes too long it would be ok for the result to be
> incorporated in some future cycle of the main loop, resulting in the
> calculation being done less and less often and the main loop executing some
> stop behavior.
> My question: Is there a possibility in Python (either with the threading
> module or with Twisted's non-threading style) to prioritize the two
> (pseudo-)concurrent methods so that the main tread is further on executed
> every ~200ms and the calculation thread being executed only in "idle" time
> slots?
>
> Thanks,
> wr

Hi,

I suggest taking a look a PEP 342
http://www.python.org/dev/peps/pep-0342/. The new coroutines capability
in Python 2.5 seems to be intended for exactly what you are doing.

--
Doug Fort, Consulting Programmer
http://www.dougfort.com




More information about the Python-list mailing list