So, i have example of code with two class functions with two infinite loops:
class Bot:
def __init__(self):
self.rocket = 0
def func1(self):
while True:
self.rocket += 1
def func2(self):
while True:
print(self.rocket)
I want them func1 and func2 to work at the same time. This is just an example, i dont need solution like:
class Bot:
def __init__(self):
self.rocket = 0
def func1(self):
while True:
self.rocket += 1
print(self.rocket)
Because i want a method how to run two functions with infinite loops in class ;) Thanks!I tried this, but causes errors:
from multiprocessing import Process
class Bot:
def __init__(self):
self.rocket = 0
def func1(self):
while True:
self.rocket += 1
def func2(self):
while True:
print(self.rocket)
if __name__ == '__main__':
p1 = Process(target=func1)
p2 = Process(target=func2)
p1.start()
p2.start()