Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25744
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <bruce.sherwood@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '21,': 0.07; 'c++,': 0.07; 'python': 0.09; '(written': 0.09; 'callback': 0.09; 'called.': 0.09; 'explicitely': 0.09; 'imported': 0.09; 'received:mail- vc0-f174.google.com': 0.09; 'thread,': 0.09; 'gui': 0.11; 'thread': 0.11; 'sat,': 0.15; '"your': 0.16; 'subject:import': 0.16; 'suggestion.': 0.16; 'thread.': 0.16; 'true:': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'module': 0.19; 'import': 0.21; 'driven': 0.22; 'subject:problem': 0.22; "user's": 0.22; 'bruce': 0.23; 'sets': 0.23; 'statement': 0.23; 'this:': 0.23; "i've": 0.23; 'second': 0.24; 'connected': 0.24; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'fine': 0.28; 'initial': 0.28; 'environment': 0.29; 'cocoa': 0.29; 'invoke': 0.29; 'occurred': 0.29; 'received:209.85.220.174': 0.29; 'writes:': 0.29; 'skip:_ 10': 0.29; "i'm": 0.29; 'primary': 0.30; 'code': 0.31; 'mac': 0.32; 'running': 0.32; 'environment,': 0.33; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'received:209.85.220': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'visual': 0.36; 'correctly': 0.37; 'execute': 0.37; 'skip:3 10': 0.37; 'usual': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'situation': 0.62; 'more': 0.63; 'jul': 0.65; 'box,': 0.69; 'rendering': 0.71; '100': 0.78 |
| 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=FV6WAoPDRAjUTSZm/E2WZZJ07nnOSGryezqALkXeeOU=; b=b2Fuuji7kVAYtKV4xrsBONBFoMYC3ChzDcbRQQRY6HmuUU/kK0tlCUdP28lf0g4/or 7k6mczRaLyUlCnTN1UTQmhKhvX5hoM25kb61KaCyeyqI2l/a9y49tNuqc167HAH82KzJ 3gnzXrggeZ/e0TT6kPaACY8NMFzzxlF8yPnmDt+TxGyuO60GvS0xyOKk6G2nVeM/vSbi SwaWrAZ2+RbUadhsSc2iv7E/TL6SvYhLUe9rXFng0Um983tMb+MefY6Fmak5vnSKGCPh fYf0G77QCNsyGhPq8fcFfJELG/8Sufz1dkb/hzn7YJiUtOIgJqsAHbkn4c8kTcBtDAvk 0Z7g== |
| MIME-Version | 1.0 |
| In-Reply-To | <87a9yt7bw6.fsf@handshake.de> |
| References | <CA+WuaScBDU_5LcrCrTtDr6N3gHCk9hQ03fA=DT359GCRY=a=KQ@mail.gmail.com> <CA+WuaSeRExxaD9yCNWhXoWqsV_ZqP8DOvdErMRdNS-H_UtzQyg@mail.gmail.com> <87a9yt7bw6.fsf@handshake.de> |
| Date | Sat, 21 Jul 2012 08:54:53 -0600 |
| Subject | Re: A thread import problem |
| From | Bruce Sherwood <bruce.sherwood@gmail.com> |
| 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 <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.2383.1342882496.4697.python-list@python.org> (permalink) |
| Lines | 43 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1342882496 news.xs4all.nl 6924 [2001:888:2000:d::a6]:44159 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:25744 |
Show key headers only | View raw
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? 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. The original instance of A won't get past its initial import statement because the main loop won't return to it. Bruce Sherwood On Sat, Jul 21, 2012 at 2:32 AM, Dieter Maurer <dieter@handshake.de> wrote: > Bruce Sherwood <bruce.sherwood@gmail.com> writes: >> ... >> from visual import box, rate >> b = box() >> while True: >> rate(100) # no more than 100 iterations per second >> b.pos.x += .01 >> >> This works because a GUI environment is invoked by the visual module >> in a secondary thread (written mainly in C++, connected to Python by >> Boost). The OpenGL rendering of the box in its current position is >> driven by a 30-millisecond timer. This works fine with any environment >> other than Mac Cocoa. >> >> However, the Mac Cocoa GUI environment and interact loop are required >> to be the primary thread, so the challenge is to have the visual >> module set up the Cocoa environment, with the user's program running >> in a secondary thread. Any ideas? > > The usual approach to this situation is to invoke the user code via > a callback from the UI main loop or invoke it explicitely > after the UI system has been set up immediately before its main loop > is called. Might look somehow like this: > > main thread: > > from thread import start_new_thread > from visual import setup_gui, start_main_loop > setup_gui() # sets up the GUI subsystem > start_new_thread(lambda: __import__(<your module>), ()) > start_main_loop()
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: A thread import problem Bruce Sherwood <bruce.sherwood@gmail.com> - 2012-07-21 08:54 -0600
csiph-web