May-24-2019, 08:21 PM
Now you run a infinity loop(while True) with no break out of the loop.
So need a way to get value out,one way can by to rewire it so it's a generator.
So need a way to get value out,one way can by to rewire it so it's a generator.
# Accelerator.py import random import time def foo(): while True: time.sleep(3) revs_pc = random.randint(1,10) yield revs_pc
# bar.py import Accelerator for i in range(10): revs_pc = next(Accelerator.foo()) revs_pc += 9 # do something with revs_pc value print(revs_pc)
Output:12
16
13
11
10
10
15
10
19
14