Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25767
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <d@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'initialize': 0.05; '21,': 0.07; 'function,': 0.07; 'see:': 0.07; 'constants.': 0.09; 'imported': 0.09; 'script,': 0.09; 'cc:addr:python-list': 0.10; 'thread': 0.11; 'sat,': 0.15; 'exceptions.': 0.16; "module's": 0.16; 'statement.': 0.16; 'subject:import': 0.16; 'suggestion.': 0.16; 'threading': 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; 'cc:2**0': 0.23; '(you': 0.23; 'bruce': 0.23; "haven't": 0.23; 'cc:no real name:2**0': 0.24; 'script': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'am,': 0.27; 'module.': 0.27; 'description,': 0.29; "i'm": 0.29; 'function': 0.30; 'figure': 0.30; 'code': 0.31; 'url:python': 0.32; 'docs': 0.33; 'thanks': 0.34; 'clear': 0.35; 'pm,': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'should': 0.36; 'possible': 0.37; 'two': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'nothing': 0.38; 'url:docs': 0.38; 'received:192': 0.39; 'little': 0.39; 'received:192.168': 0.40; 'end': 0.40; 'your': 0.60; 'side': 0.61; 'more': 0.63; 'making': 0.64; 'harder': 0.65; 'jul': 0.65; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'special': 0.73; 'thing,': 0.84; 'angel': 0.93 |
| Date | Sat, 21 Jul 2012 16:53:29 -0400 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 |
| MIME-Version | 1.0 |
| To | Bruce Sherwood <bruce.sherwood@gmail.com> |
| Subject | Re: A thread import problem |
| References | <CA+WuaScBDU_5LcrCrTtDr6N3gHCk9hQ03fA=DT359GCRY=a=KQ@mail.gmail.com> <CA+WuaSeRExxaD9yCNWhXoWqsV_ZqP8DOvdErMRdNS-H_UtzQyg@mail.gmail.com> <87a9yt7bw6.fsf@handshake.de> <CA+WuaSc1wzUqUyw_=QqryN2H_FKYqxspnuqBWECVq5-DH2Lcvg@mail.gmail.com> <500AD83B.1090403@davea.name> <CA+WuaSdcBk+0jyT2P_RUo=AjPSSm-VQzRG7ENiy4ZsdjzVqT9g@mail.gmail.com> |
| In-Reply-To | <CA+WuaSdcBk+0jyT2P_RUo=AjPSSm-VQzRG7ENiy4ZsdjzVqT9g@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:2VEVpRxJ4a/LDpc/9dRSt8TSUqO70Y6UVSDHiuPaXq3 s9NxOK6bj4FjuNNHjaRFL3MriD97GpmdlMwTqVYgNz6SdF74O/ xiF64QMzl8/4IkebNKlzBFdqG1w7CzP6A6ZHBWTm1ORa7RCF+d 24oBBZVg54hGl4LvNRSJ+rEVbpINW7KUHmv/3Snhvqqh7bueFW JdXNxA08xN1V4+G1xxfY5gGlzepHrOCsXbwhRF/oyWgEuDhj+o 41Fm7EqbSsbG3vfCsqmyYVGWcZGQfHWwjy2CLTvxP1vO8i53K+ bI1TQ+RRYvXzBBvvVUMLqkWZthZRzq6pRjOaqhjraRmW5puTA= = |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | d@davea.name |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2398.1342904033.4697.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1342904033 news.xs4all.nl 6870 [2001:888:2000:d::a6]:48501 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:25767 |
Show key headers only | View raw
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 <d@davea.name> 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: http://docs.python.org/library/threading.html " ... an import should not have the side effect of spawning a new thread and then waiting for that thread in any way..." -- DaveA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: A thread import problem Dave Angel <d@davea.name> - 2012-07-21 16:53 -0400
csiph-web