SMP, GIL and Threads

catsup ramadon.rexx at gmail.com
Fri Dec 16 11:05:41 EST 2005


Hi,

I have an app written under version Python 2.3.5.  The problem I'm
having is that it hangs on one of its threads.  The thread that hangs
does updates to a standard dictionary shared with another thread that
only reads this dictionary.  This app works beautifully on a single
processor boxes in my testing environment, but this problem quickly
occurs when the software runs on a dual cpu SMP blade server with
hyperthreading turned off, Windows 2003 server.

I do not bother using application level locks because I figure the GIL
is going to do the job for me, and because with one thread doing
updates and the other only reading, things remain consistent logically
for the app.  The app will not have a problem if the dictionary changes
just before it does a read.

I have searched this group on this subject and seen one warning against
sharing objects between threads.  I don't recall every writing a
threaded app that didn't share data between threads in some way.  I've
also seen a recomendation in this list against using threads at all
with Python.  I'm hoping that is an extreme view and not general wisdom
here.  Python has never failed me when analysis indicated that it would
be the correct tool for the job.

Thank you for your time and attention.

Randy




More information about the Python-list mailing list