import, functions, and threading
From: Aahz (aahz_at_pythoncraft.com)
Date: 03/12/04
- Next message: Christopher Koppler: "Re: put your money where your mouse is, or why I prefer Spanish to English: a proposal"
- Previous message: Paul McGuire: "Re: put your money where your mouse is,or why I prefer Spanish to English: a proposal"
- Next in thread: Ian Bicking: "Re: import, functions, and threading"
- Reply: Ian Bicking: "Re: import, functions, and threading"
- Reply: Phillip J. Eby: "Re: import, functions, and threading"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Christopher Koppler: "Re: put your money where your mouse is, or why I prefer Spanish to English: a proposal"
- Previous message: Paul McGuire: "Re: put your money where your mouse is,or why I prefer Spanish to English: a proposal"
- Next in thread: Ian Bicking: "Re: import, functions, and threading"
- Reply: Ian Bicking: "Re: import, functions, and threading"
- Reply: Phillip J. Eby: "Re: import, functions, and threading"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|