question to start_new_thread in thread
Peter Hansen
peter at engcorp.com
Thu Oct 2 14:08:18 EDT 2003
Thomas Schmid wrote:
>
> I wrote a tcp server which listens on a port. When he gets a new
> connection, he starts a new thread like this:
> thread.start_new_thread(self.ConnectionHandler, (conn,))
> where conn is the socket for the connection.
>
> After I started the server, I can see one running process under Linux,
> which is ok. But once I connected to the Server, I always see two
> processes where one is the parent of the other. I think this should be
> normal behavier as long as the connection is established. But I also
> see two processes when the connection is finished. So I thought that I
> don't quit the thread for the connection correctly. Then I should see
> three processes after I started a second connection, but I don't.
> There are alwys just the two of them.
>
> My question now is: does python make a thread pool where it does not
> really quit the threads but instead reuses them if necessary? Or does
> it need a second process to administrate threads?
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
More information about the Python-list
mailing list