On Fri, Jul 22, 2011 at 7:29 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote: > Is it really necessary to hold the import lock for so long? > Presumably the import lock is there to protect access to > things like sys.modules. Is that all? Could it be released > after the module code is loaded and sys.modules has been > updated, but before executing the module body? No, because we don't know if we're keeping it until the module body is executed successfully and we don't want other threads to see the partially initialised module. There's a reason the docs say never to spawn and then wait for threads as a side effect of import (http://docs.python.org/library/threading#importing-in-threaded-code) If you want to delegate main module execution to another file, then runpy.run_module is available. Antoine's fine grained import locking patch (or something along those lines) would improve matters, but currently causes its own deadlock problems. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4