Sockets and threads

Alan Kennedy alanmk at hotmail.com
Wed Jun 11 06:05:27 EDT 2003


Byron Morgan wrote:

> If I monitor a socket connection or even jsust listen to a socket in a
> thread, Python's cpu usage expands to use all available processor time.

Hmm, this sounds like something is wrong, for sure.

A few questions that would be helpful if you could answer:

1. How many threads are you creating? At what stage of connection processing?
2. How many of those threads are 'listen'ing for socket connections?
3. If you answered "more than 1" for question 2, that's a problem.
4. When you receive a new connection, do you create a new thread, or pass
control to an existing thread?
5. Does each thread do blocking or non-blocking reads on the socket?

If you can answer those, it should hopefully become plainly clear what is going
wrong.

-- 
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/mailto/alan




More information about the Python-list mailing list