[BangPypers] threading problem

Abhinav Sarkar abhinav.sarkar at gmail.com
Fri Mar 27 04:14:41 CET 2009


OOMMEN KM wrote:
> Hey,
> I am trying to write an application which reads xml messages from a 
> socket, analyzes the message and sends back a resultant message.
>
> This should be an application in which one thread will read incoming 
> xml messages and push them to a queue.
> As these messages needs to be processed independently, another set of 
> threads should get the messages from the queue and process them.
>
> The problem I face is i get less performance rate than the one without 
> threads.
>
> Can anyone help me with some tips for making it better or things to 
> remember in python threading.
> Is there any way to kill a thread explicitly.
>
> Thanking you in advance.
This might be due to the Global Interpreter Lock 
[http://docs.python.org/glossary.html#term-global-interpreter-lock]. You 
should try using the multiprocessing module 
[http://docs.python.org/library/multiprocessing.html] which uses sub 
processes instead of threads. It has the same API as the threading 
module so there should not be much problem in shifting your code from 
threading to multiprocessing.

-- 
Abhinav Sarkar

Web: http://claimid.com/abhin4v
Twitter: http://twitter.com/abhin4v
---------
The world is a book, those who do not travel read only one page.



More information about the BangPypers mailing list