I have some code that needs to be in a separate thread and this code is a different class completely. I am using the multiprocess.Queue queue to share the data. Basically I want the parent base class (also the program driver) to make an instance of some other class and put that instance into a queue and send the queue to the new threaded class. When the threaded class runs and finally comes up with a value I want it to directly call a function from the instance inside the queue that was passed.
Instead, the thread terminates and calls the finally block that I have set up. How do I do this in python?
from multiprocessing import queue
import thread
class a():
def main(self):
self.classB = b()
self.classC = C()
self.queue = Queue()
self.queue.put_nowait(self.classC)
thread.start_new_thread(self.classB.run, (self.queue))
#do stuff
class b():
def run(self, q):
#do stuff in try clause
self.listen(q)
def listen(self, q):
c = q.get()
c.someClassCMethod
EDIT: Okay so I am now using Queue.Queue() instead. I couldn't find what the threading Queue that was mentioned.... I still am having trouble sending the instance of classC to classB and using it.