Suppose I want to restart an event loop by an interval time, such as below:
from time import sleep
def event_loop():
print('Restart')
while True: # Note :: This is an indefinite loop
# Process some stuff.
print("I'm a process")
sleep(1)
magic_tool(interval_time=5, func=event_loop)
Expected result:
Restart
I'm a process
I'm a process
I'm a process
I'm a process
I'm a process
Restart
I'm a process
I'm a process
I'm a process
I'm a process
I'm a process
Restart
I'm a process
.
.
.
I read about twisted
, threading.Time
and apscheduler.scheduler
but I couldn't do that.
I think I can do it by async.timeout.timeout()
but I'm using Python2.7