Re: A thread import problem

Discussion in 'Python' started by Dieter Maurer, Jul 22, 2012.

  1. Bruce Sherwood <> 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__(...)").
     
    Dieter Maurer, Jul 22, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Seefeld
    Replies:
    3
    Views:
    963
  2. per9000
    Replies:
    7
    Views:
    413
    Magnus Lycka
    Feb 27, 2006
  3. Bruce Sherwood

    A thread import problem

    Bruce Sherwood, Jul 19, 2012, in forum: Python
    Replies:
    0
    Views:
    161
    Bruce Sherwood
    Jul 19, 2012
  4. Dennis Lee Bieber

    Re: A thread import problem

    Dennis Lee Bieber, Jul 19, 2012, in forum: Python
    Replies:
    0
    Views:
    176
    Dennis Lee Bieber
    Jul 19, 2012
  5. Dieter Maurer

    Re: A thread import problem

    Dieter Maurer, Jul 19, 2012, in forum: Python
    Replies:
    0
    Views:
    145
    Dieter Maurer
    Jul 19, 2012
Loading...

Share This Page