Reputation: 1
I need to create simple server, which will run some kind of infite loop, for example:
try:
while True:
time.sleep(1)
print ("I'm Running",time.clock())
I need server to kill the loop after sometime and then run it again, and everything until i interupt it. Can you help me please? Probably will use subprocess
Upvotes: 1
Views: 59
Reputation: 995
How about this:
import time
while True:
try:
time.sleep(1)
print("I'm Running",time.clock())
except KeyboardInterrupt:
print("Don't stop me now! I'm having such a good time...")
time.sleep(x) # instead of x put the number of
# seconds you want before it will start again
Upvotes: 1