Open anthonyrisinger opened 9 years ago
Good point, we should get that fixed. Taken from a framework we're using pesos with.. we're not using the join()
method.
# Kick off the pesos scheduler and watch the magic happen
thread = threading.Thread(target=driver.run)
thread.setDaemon(True)
thread.start()
# Wait here until the tasks are done
while thread.isAlive():
time.sleep(0.5)
run()
calls join()
internally, but what you have also allows SIGINT
because you are in the main thread, and you passed a "timeout" to sleep()
-- the interpreter will get a chance to raise KeyboardError
.
Your pesos thread will not shutdown cleanly though (marked daemon and never called stop()
)... not necessarily a problem, but something to keep in mind if you perform any state/syncing activities.
Your pesos thread will not shutdown cleanly though (marked daemon and never called stop())... not necessarily a problem, but something to keep in mind if you perform any state/syncing activities.
Good shout, i'll double check this. Thanks!
With the current impl, it's not possible to handle signals like
SIGINT
(KeyboardInterrupt) becausejoin()
callsself.lock.wait()
with no timeout -- the signal is caught and queued for handling but the main thread is never given a chance to respond (waiting for compactor thread tonotify()
).Adding a timeout periodically gives the main thread a chance to respond.
Workaround: