[Pythonmac-SIG] Re: urllib and ftplib hang in bundle but not when run directly

Michael Hudson mwh at python.net
Fri May 14 06:56:24 EDT 2004

"Russell E. Owen" <rowen at cesmail.net> writes:

> In article <rowen-C76C8E.09571605052004 at sea.gmane.org>,
>  "Russell E. Owen" <rowen at cesmail.net> wrote:
>>I am having trouble with some ftp code. On some platforms it works fine 
>>and on others it reliably hangs....(including MacOS X command-line
>>it works, but a bundled app version of the identical code fails)
> After some experimentation, I found the hanging was occurring in ftplib. 
> It delays importing re and compiling two regular expressions until they 
> are needed, and the thread hangs both on the import and (if I modify 
> ftplib to import re in advance) on the compilation. Modifying ftplib to 
> do both jobs in advance (when first imported) fixes the problem.

Um.  Python has an 'import lock' so only one thread can be importing a
module at the same time.

Do you have code like this:

def main():


i.e. that does things as a result of being imported?  You should stop
that :-)


  well, take it from an old hand: the only reason it would be easier
  to program in C is that you can't easily express complex problems
  in C, so you don't.                   -- Erik Naggum, comp.lang.lisp

More information about the Pythonmac-SIG mailing list