Say I have 3 Processes:
In Process A, there is an infinite loop that does something with self.marker. But at the same time, self.marker also needs to be updated every 1 minute so a threading.Timer is implemented to do this.
This Timer will be running within Process A as a separate thread like so:
class A(Process):
def _init__(self):
self.marker = True
self.q = Queue()
def run(self):
threading.Timer(60, updater).start()
while True:
if not self.q.empty():
item = self.q.get()
self.marker = item
print(self.marker)
def updater(self):
self.q.put(not self.marker)
threading.Timer(60, updater).start()
class B(Process):
def _init__(self):
def run(self):
class C(Process):
def _init__(self):
def run(self):
a = A()
b = B()
c = C()
a.start()
b.start()
c.start()
My questions are:
1) In this code, is self.marker
being safely updated through the use of a queue? Or is a queue unnecessary
2) Should self.q
be a queue.Queue()
or a multiprocessing.Queue
?