I am running a small python code background.py
as follows:
class Background:
def __init__(self):
self.q = 0
def run(self):
while True:
print(f"test, q={self.q}")
time.sleep(5)
def setq(self, x):
self.q += x
print(f"New value q={q}")
if __name__ == "__main__":
bg = Background()
bg.run()
and I want to start a small python code in another terminal to access this running python code and to execute the method setq
so that the value in the running code is being changed. How can this be done easiest?