Python share CPU time?
Yannick
yannick.leteigner at gmail.com
Thu Aug 10 19:46:34 EDT 2006
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.
More information about the Python-list
mailing list