multithreading

Skip Montanaro skip at pobox.com
Thu May 23 16:41:07 EDT 2002


    >> > Can anyone point me to a useful tutorial on multithreading?

    >> One advice: Avoid multithreading like the plague. 

    Cliff> I think this is a bit of an overstatement.  Many problems are
    Cliff> best expressed as multithreaded programs.

I agree.  I have an xml-rpc server that was single-threaded for several
years.  I always meant to multi-thread it, but I feared introducing
instability in the server.  When I finally bit the bullet I discovered it
wasn't all that difficult.  You have to exercise care to make sure all your
shared objects are protected by locks or are contained in Queue objects.
You may also have to internally cap the number of active threads.  For
example, my xml-rpc server creates a thread to handle each connection.  The
number of threads is proportional to the number of requests coming into the
websites it serves.  The number of active threads is effectively capped by a
Queue object which contains a set of cached MySQLdb connection objects.

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
"Excellant Written and Communications Skills required" - seen on chi.jobs





More information about the Python-list mailing list