python - Time managment with queue and threads -



python - Time managment with queue and threads -

i have object can used thread time , have stop using predefined period (like banish x seconds). thread can utilize again.

i want suggestions of how should implement this, thinking of fifo queue holding key,value pair each object. object key , period can start working 1 time again value. when object has stop working added queue time has been added. have check every x seconds if first element in queue can used, why think not solution problem.

what best way implement this? i'm using python, examples in python appreciated. thanks.

consider sched module. lets submit jobs run in future.

example docs:

>>> import sched, time >>> s = sched.scheduler(time.time, time.sleep) >>> def print_time(): print "from print_time", time.time() ... >>> def print_some_times(): ... print time.time() ... s.enter(5, 1, print_time, ()) ... s.enter(10, 1, print_time, ()) ... s.run() ... print time.time() ... >>> print_some_times() 930343690.257 print_time 930343695.274 print_time 930343700.273 930343700.276

python multithreading

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -