On 10/19/07, Facundo Batista <[EMAIL PROTECTED]> wrote: > 2007/10/19, Adam Olsen <[EMAIL PROTECTED]>: > > > The solution then is, if your python file will ever be imported, you > > must write a main function and do all the work there instead. Do not > > write it in the style of a script (with significant work in the global > > scope.) > > I had this a as a good coding style, not so mandatory. > > I agree with you that the OP shouldn't be doing that, but note that > the main problem arises here because it's completely unpredictable the > import in strptime for an external user. > > Do you recommend to close the bug as "won't fix" saying something like... > > The deadlock happens because strptime has an import inside it, and > recursive imports are not allowed in different threads. > > As a general rule and good coding style, don't run your code when the > module is imported, but put it in a function like "main" in the second > file, > import it and call it from the first one. This will solve your problem. > > Note that this happens to you with strptime, but could happen with a lot > of functions that do this internal import of something else. So, > you'll never > be sure. > > What do you think?
Whether this is a minor problem due to poor style or a major problem due to a language defect is a matter of perspective. I'm working on redesigning Python's threading support, expecting it to be used a great deal more, which'd push it into the major problem category. For now I'd leave it open. -- Adam Olsen, aka Rhamphoryncus _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com