set_timeout/clear_timeout and set_interval/clear_intervalimplemented with the threading module.
These functions may be used as decorators. Also important is that the python analogues take time arguments in seconds, not milliseconds, in order to be consistent with the standard library.
Much of python does not “play nice” with threading. You have been warned.
(I looked into a signal-based approach, but this is limited. Another approach would be to depend on an event loop, such as twisted.reactor.)
>>> from hiatus import set_interval >>> @set_interval(1.00) ... def dave_grohl(): ... print "THE BEST" ... >>> THE BEST THE BEST THE BEST THE BEST THE BEST
>>> def note(): ... print "HUGE SUCCESS"... >>> hiatus.set_timeout(lambda: hiatus.clear_interval(glados), 6.0) <hiatus.set_timeout object at 0xb770468c> >>> glados = hiatus.set_interval(note, 1.000) >>> HUGE SUCCESS HUGE SUCCESS HUGE SUCCESS HUGE SUCCESS
Visit <https://github.com/jesusabdullah/hiatus> .