Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: A thread import problem

Thread Tools

Re: A thread import problem

Dave Angel
Posts: n/a
On 07/21/2012 04:36 PM, Bruce Sherwood wrote:
> Thanks much for this clear statement. I hadn't managed to find any
> documentation on this specific issue.
> Bruce Sherwood
> On Sat, Jul 21, 2012 at 10:26 AM, Dave Angel <(E-Mail Removed)> wrote:
>> Two of the things you mustn't do during an import:
>> 1) start or end any threads
>> 2) import something that's already in the chain of pending imports.
>> (otherwise known as recursive imports, or import loop). And there's a
>> special whammy reserved for those who import the script as though it
>> were a module.
>> Like any rule, there are possible exceptions. But you're much better
>> off factoring your code better.
>> I haven't managed to understand your software description, so i'm not
>> making a specific suggestion. But I know others have pointed out that
>> you should do as little as possible in top-level code of an imported
>> module. Make the work happen in a function, and call that function from
>> the original script, not from inside some import. An imported module's
>> top-level code should do nothing more complex than initialize module
>> constants.
>> --
>> DaveA

(You top-posted, which makes it harder to figure out who said what.)

For docs on the threading thing, see:

" ... an import should not have the side effect of spawning a new thread
and then waiting for that thread in any way..."



Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: A thread import problem Dieter Maurer Python 0 07-19-2012 08:31 AM
Re: A thread import problem Dennis Lee Bieber Python 0 07-19-2012 12:47 AM
A thread import problem Bruce Sherwood Python 0 07-18-2012 11:03 PM
problem(s) with import from parent dir: "from ../ import sir_robin" per9000 Python 7 02-27-2006 06:36 PM
Problem with import "from omniORB import CORBA, PortableServer" Stefan Seefeld Python 3 04-11-2005 08:54 PM