Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'initialize': 0.05; '21,': 0.07; 'function,': 0.07; 'constants.': 0.09; 'imported': 0.09; 'received:mail-vc0-f174.google.com': 0.09; 'script,': 0.09; 'sat,': 0.15; 'exceptions.': 0.16; "module's": 0.16; 'statement.': 0.16; 'subject:import': 0.16; 'suggestion.': 0.16; 'threads': 0.16; 'top-level': 0.16; 'wrote:': 0.17; 'pointed': 0.17; 'module': 0.19; 'issue.': 0.20; 'pending': 0.20; 'import': 0.21; 'subject:problem': 0.22; 'bruce': 0.23; "haven't": 0.23; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'module.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'description,': 0.29; 'received:209.85.220.174': 0.29; "i'm": 0.29; 'function': 0.30; 'code': 0.31; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'clear': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'should': 0.36; 'possible': 0.37; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'nothing': 0.38; 'to:addr:python.org': 0.39; 'little': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'your': 0.60; 'more': 0.63; 'making': 0.64; 'jul': 0.65; 'special': 0.73; 'angel': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=w+LLxDvAOVR4YiRnfVWffboci/PKqBxm2Mzkn8ZBDOI=; b=z5VYy2VtlfRowqr/61B0CHKmyKcm+gKE9GIWbchf7Ugjlh12l0DC/3BuYrU4bi9vvr htRf3n/QUmEpgFUQ3oSqCPsR2HWDEKiA9j2pU1ZE7dPBf920wJKsf/AdSk1UDFlfO9bM 7nqwh8bT8Fd63w1/e4WRIKmz6/j017Ft6FLfEHgyMk2JETZO995/4rTWuAKhEQCf9CbQ BN787QecpsmODEU8n4chvYmrZgtkHL44Z51ZMufRWrcaaIml1EWAQ0/5x5K61AjVkxwO 1yD5Ur3Ox/CwRCpQQ99RWwqoFK/ysha1uW9bpgnrxS65FtGLpR3JqI/WaD1/8xhJSfYI LDAQ== MIME-Version: 1.0 In-Reply-To: <500AD83B.1090403@davea.name> References: <87a9yt7bw6.fsf@handshake.de> <500AD83B.1090403@davea.name> Date: Sat, 21 Jul 2012 14:36:41 -0600 Subject: Re: A thread import problem From: Bruce Sherwood To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342903004 news.xs4all.nl 6915 [2001:888:2000:d::a6]:45092 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25766 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 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 > >