question to start_new_thread in thread
peter at engcorp.com
Fri Oct 3 15:03:10 CEST 2003
Thomas Schmid wrote:
> Peter Hansen <peter at engcorp.com> wrote in message news:<3F7C6992.69B05F18 at engcorp.com>...
> > I can't answer this other than to say stop using "thread" and start
> > using "threading". If you are using "threading" and your threads stop,
> > they disappear as you would expect. I don't think anyone is supposed
> > to use "thread" anymore... and it might solve your problems.
> > -Peter
> I tried it out and wrote instead of thread.start_new_thread this:
> connThread = Thread(target=self.ConnctionHandler, args=(conn,))
> The result is exactly the same. First, I see only one process. But as
> soon as I connect to the server, there are two processes which always
> are there even if I disconnect. But still, there are never more then
> two processes. I think the other process is a controle thread because
> I found this in the documentation:
> "There is a ``main thread'' object; this corresponds to the initial
> thread of control in the Python program. It is not a daemon thread."
So, logically, one would conlude that your thread never exits, even when
you disconnect. You'd better post code, or start sticking print statements
inside until you discover what is actually happening in your code.
Or replace the thread target with a function that does a simple time.sleep()
and observe the results. You should see the process exit, which ought to
prove to you that the problem is with your specific server code, and not
threads in Python.
More information about the Python-list