multithreading - Python: [Help] Best use of asynchronous timer (Non Blocking Timer) -
my question if have thread program runs in infinite loop , each loop simulation step, @ every loop there might request timer something. sounds easy confusing thing want loop continue , not wait timer , "do something" statement happen if timer fired. clarification:
class thread1(threading.thread): def __init__(slef): threading.thread.__init__(self) def run(self): while true: #do step 1 #do step 2 #if input available:>start_timer(seconds) #if timer(user input seconds) finished step 3 #continue looping
again problem have i've tried use timer threading library (from threading import timer) show execution error, while sleep function sleeps , whole simulation stops wont good.
Comments
Post a Comment