> This loops every 5 seconds regardless of how long the remainder of the > loop > takes (as long as it is somewhat less than 5 seconds) > > from time import time, sleep > > next_time = time()+5 > while True: > sleep(next_time-time()) > next_time+=5 > # ... > >
I do not know if it is pertinent with the topic, but uWSGI has tons of (cheap, very cheap compared with solutions like celery) facilities to allow this sort of tasks: http://projects.unbit.it/uwsgi/wiki/Decorators -- Roberto De Ioris http://unbit.it