import, functions, and threading

From: Aahz (aahz_at_pythoncraft.com)
Date: 03/12/04


Date: 12 Mar 2004 01:14:43 -0500

There were some posts recently discussing whether it's poor style to put
import statements inside functions. I recently got reminded that there's
one very good reason to avoid it: Python has an import lock that blocks
more than one thread from executing import statements. Putting import
statements inside functions that might be called in a threaded
environment is asking for deadlock trouble.

-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/
"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python


Relevant Pages

  • Re: OT:" A very disturbed, unravelled person"
    ... it became clear I may never be able find a satisfactory "reason" ... He true core should be less the 10%...The 30% who is dead set against ... Look at the posts here! ... Brain dude have made a lot of progress "understanding" serial killers. ...
    (rec.music.beatles)
  • Re: I hate to admit Engineer was right but too much cross-posting is ruining SRQ
    ... politeness would seem to require not doing something that at least ... (and I do mean, reason, not excuse) ... to avoid being killfiled) I will do so silently so as not to offend ... The harassment always referenced posts to soc.religion.quaker. ...
    (soc.religion.quaker)
  • Re: About Soundhaspriority
    ... posts, 99% of which are trying to troll me. ... didn't see a reason not to believe it. ... energy to waste on worthless fools. ... Look who's talking, ya dirty hypocrite. ...
    (rec.audio.opinion)
  • Re: OT:" A very disturbed, unravelled person"
    ... it became clear I may never be able find a satisfactory "reason" ... He true core should be less the 10%...The 30% who is dead set against ... Look at the posts here! ... Brain dude have made a lot of progress "understanding" serial killers. ...
    (rec.music.beatles)
  • Re: Outlook Toolbar in Access
    ... I AM NOT referring to my answering over 1000 NG posts. ... me for help after not getting the help they need from the newsgroups (not ... and now I am getting between 5 and 10 new requests for help a week. ... My reason for doing this is the same reason why other consultants are using ...
    (comp.databases.ms-access)