Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25795

Re: A thread import problem

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '(instead': 0.09; 'imported': 0.09; 'loop.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'gui': 0.11; 'thread': 0.11; '"your': 0.16; 'called,': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:import': 0.16; 'suggestion.': 0.16; 'module': 0.19; 'putting': 0.20; 'import': 0.21; 'meant': 0.21; 'supposed': 0.21; 'subject:problem': 0.22; 'bruce': 0.23; 'sets': 0.23; "i've": 0.23; 'second': 0.24; 'header :User-Agent:1': 0.26; 'skip:" 20': 0.26; 'separate': 0.27; 'propose': 0.27; 'header:X-Complaints-To:1': 0.28; 'environment': 0.29; 'changed.': 0.29; 'implies': 0.29; 'loop,': 0.29; 'occurred': 0.29; 'writes:': 0.29; 'starts': 0.29; 'skip:_ 10': 0.29; "i'm": 0.29; 'function': 0.30; 'code': 0.31; 'suggestion': 0.32; 'message.': 0.33; 'animation': 0.33; 'environment,': 0.33; 'to:addr:python-list': 0.33; 'thanks': 0.34; 'received:org': 0.36; 'but': 0.36; 'charset:us-ascii': 0.36; 'correctly': 0.37; 'execute': 0.37; 'does': 0.37; 'two': 0.37; 'previous': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'received:217': 0.68; 'proposal,': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dieter Maurer <dieter@handshake.de>
Subject Re: A thread import problem
Date Sun, 22 Jul 2012 08:04:37 +0200
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>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Gmane-NNTP-Posting-Host pd9e08f42.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
Cancel-Lock sha1:a9HaXoI0iWZ9ePxzCZyP2BHtJiE=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
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.2417.1342937096.4697.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1342937096 news.xs4all.nl 6959 [2001:888:2000:d::a6]:44525
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:25795

Show key headers only | View raw


Bruce Sherwood <bruce.sherwood@gmail.com> writes:

> Thanks much for this suggestion. I'm not sure I've correctly
> understood the operation "start_new_thread(lambda: __import__(<your
> module>), ())". By "your module" do you mean the user program which
> imported the module that will execute start_new_thread?

By "your_module", I meant what you have called "user.py" elsewhere
in this thread -- the thing that does the animation.

Of course, my suggestion implies that "visual.py" is somewhat changed.
It is supposed to no longer set up the GUI environment automatically
but do so only when its "setup_gui" function is called, and starting
the GUI main loop, too, is no longer automatic but explicite.

> It hadn't
> occurred to me to have A import B and B import A, though now that you
> describe this (if that's indeed what you mean) it makes sense.

I do not propose to do that -- it can lead to problems.

In my proposal, you have two modules: one the "main" module which
sets up the GUI environment, starts the animation in a separate thread
and then activate the GUI main loop. The second module contains
the code you have shown in a previous message.

Of course, the second module can be eliminated by putting its content
into a function and then calling this function in the "start_new_thread"
(instead of "lambda: __import__(...)").

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: A thread import problem Dieter Maurer <dieter@handshake.de> - 2012-07-22 08:04 +0200

csiph-web