Multithreading and locking

Aahz aahz at pythoncraft.com
Thu Sep 18 18:29:16 CEST 2003


In article <bkbv5l$kgl$1 at bagan.srce.hr>, Ivan Voras <ivoras at fer.hr> wrote:
>
>Is it true what I heard (as a "rumour" of sorts), that in multithreaded
>Python programs global variables are already automagically protected by
>mutexes? Can someone clarify on that?

In addition to Duncan's excellent answer, I'd suggest that if you're
using phrases like "global variables", you probably want to learn more
about how Python's object model works in addition to learning more about
writing good threaded programs.  You want to avoid sharing mutable names
across threads as much as possible.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan




More information about the Python-list mailing list