Python share CPU time?

Simon Forman rogue_pedro at yahoo.com
Thu Aug 10 22:09:57 EDT 2006


Yannick wrote:
> Thank you all for the detailled answers.
>
> What I would like to achieve is something like:
>
> # main loop
> while True:
>     for robot in robots:
>         robot.start()
>         robot.join(0.2) # wait 200ms
>         if robot.is_active():
>             robot.stop()
>     # run all the game physics, pause, frame/rate, etc...
>
> Unfortunately the stop() call doesn't exist in Python.
>
> By using a generator I would make the assumption that every robot is
> playing fair, and would yield often. But I cannot control this as
> eventually robots would be coded by third parties.
>
> Using Python scheduler would allow me to share time equally between
> each robot, but then I would loose the ability to have a main thread
> organizing everything.

This is just a dim memory, but something called lambdaMOO was (is?) a
Multi-User Dungeon that had (has?) a model of processing that allowed
you to create programmed objects that received a "budget" of processor
time.  The objects would not work if they "ran out" of processor
time...

Perhaps something like this could help you?  (Sorry to be so vague.)

HTH,
~Simon




More information about the Python-list mailing list