Re: [Python-Dev] Import lock considered mysterious

2011-07-22 Thread Antoine Pitrou
> >See http://bugs.python.org/issue9260 > > > >There's a patch there but it needs additional sophistication to remove > >deadlocks when doing concurrent circular imports. > > I don't think that approach can work, as PEP 302 loaders can > currently assume the global import lock is being held when

Re: [Python-Dev] Import lock considered mysterious

2011-07-22 Thread P.J. Eby
At 02:48 PM 7/22/2011 +0200, Antoine Pitrou wrote: See http://bugs.python.org/issue9260 There's a patch there but it needs additional sophistication to remove deadlocks when doing concurrent circular imports. I don't think that approach can work, as PEP 302 loaders can currently assume the g

Re: [Python-Dev] Import lock considered mysterious

2011-07-22 Thread Nick Coghlan
On Fri, Jul 22, 2011 at 7:29 PM, Greg Ewing 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 > upda

Re: [Python-Dev] Import lock considered mysterious

2011-07-22 Thread Antoine Pitrou
On Fri, 22 Jul 2011 21:29:23 +1200 Greg Ewing wrote: > > This whole episode seems to have resulted from a collision > between two rather obscure things: that import statements > involve locking things, and that some fairly innocuous > looking calls, such as s.encode('ascii'), can trigger an > imp

Re: [Python-Dev] Import lock considered mysterious

2011-07-22 Thread Paul Moore
On 22 July 2011 10:29, Greg Ewing wrote: > The reason for *that* was that my main module was a stub > that imported the real main module, which did all its > work directly from the module code. So the whole program > was effectively running inside an import statement and > holding onto the import

Re: [Python-Dev] Import lock considered mysterious

2011-07-22 Thread Cameron Simpson
On 22Jul2011 21:29, Greg Ewing wrote: [...] | This whole episode seems to have resulted from a collision | between two rather obscure things: that import statements | involve locking things, Necessary to avoid performing the module definitons twice when a module is imported twice, surely? | and

[Python-Dev] Import lock considered mysterious

2011-07-22 Thread Greg Ewing
I recently encountered a very mysterious bug in which a background thread would inexplicably hang while attempting to make a connection using httplib. Debugging as far as I could at the Python level led to the surprising conclusion that it was hanging while using the ascii codec to encode the hos