24 lines
614 B
Python
24 lines
614 B
Python
|
import time
|
||
|
import os
|
||
|
import random
|
||
|
|
||
|
start_ts = time.time()
|
||
|
loops = 0
|
||
|
|
||
|
while True:
|
||
|
time.sleep(1)
|
||
|
loops += 1
|
||
|
tick_ts = time.time()
|
||
|
delta = int(tick_ts - start_ts)
|
||
|
pid = os.getpid()
|
||
|
print("I'm {} and I've been running for {} seconds and did {} loops".format(pid, delta, loops))
|
||
|
chance = random.randint(0, 20)
|
||
|
if chance == 5:
|
||
|
response = input("I need some input...")
|
||
|
if len(response) == 0:
|
||
|
exit(0)
|
||
|
else:
|
||
|
print("thanks for the response, I'll reset my counter and continue now...")
|
||
|
start_ts = time.time()
|
||
|
loops = 0
|