Код: Выделить всё
import multiprocessing as mp
import time
class CycleThatDoesntStop:
shouldrun = True
def run(self):
while self.shouldrun:
print("im alive", self.shouldrun)
time.sleep(0.5)
def stop(self):
print("stop was called!")
self.shouldrun = False
def stopper(cycle_inst):
time.sleep(0.6)
print("stopping...")
cycle_inst.stop()
print("done?")
if __name__ == '__main__':
cycler = CycleThatDoesntStop()
p = mp.Process(target=stopper, args=(cycler,))
p.start()
cycler.run()
p.join()
< /code>
Почему цикл продолжает продолжаться? Это потому, что Speppr
Подробнее здесь: https://stackoverflow.com/questions/797 ... te-modifie