About object reference and threads
Laura Creighton
lac at strakt.com
Mon Jan 27 13:38:09 EST 2003
> How do I tell a Thread object what Queue object to use? I have a
> parent object that has a Queue and a Thread as members. I want the
> parent object to create the thread, tell it to write to to the Queue
> object, then start the Thread. How do I do this? How do I get a
> reference to an object?
> --
> http://mail.python.org/mailman/listinfo/python-list
Did you read http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 ?
What part of ThreadedClient didn't you understand? That's the
parent object, that has a Queue (made like this)
self.queue = Queue.Queue()
and a Thread (made like this)
self.thread1 = threading.Thread(target=self.workerThread1)
you start the thread like this:
self.thread1.start()
when workerThread1 wants to write to the queue it does this:
self.queue.put(msg)
Please let me know what confused you. I want this recipe to be really
easy to understand, and I cannot fix the confusing bits if I do not know
what they are. All the 'master' gui stuff?
Laura Creighton
More information about the Python-list
mailing list