Re: A thread import problem

Discussion in 'Python' started by Dennis Lee Bieber, Jul 22, 2012.

  1. On Sat, 21 Jul 2012 17:10:05 -0600, Bruce Sherwood
    <> declaimed the following in
    gmane.comp.python.general:


    > Thanks, but the problem I need to solve does not permit putting a
    > function like runner in the main program. I'm constrained to being
    > able to handle the API of VPython (vpython.org), which lets you write
    > programs like the following (call it user.py), which animates a 3D
    > cube moving to the right, using OpenGL:
    >
    > from visual import box
    > b = box()
    > while True:
    > b.pos.x += 0.001


    Well, based on that sample, wrap THAT as "runner"

    def runner():
    from visual import box
    b = box()
    while True:
    b.pos.x += 0.0001

    and don't /call/ runner() until after all the main system is configured.
    (And runner could, if need be, be "called" as a thread).

    Not having a Mac, I can't do tests... but everything I've seen so
    far comes down to NOT IMPORTING anything that tries to spawn threads
    /during the import/.

    A properly designed module (as I showed with my testABA.py) only
    "runs" stuff if loaded as the main program; any other use (import) only
    does imports and defines module level entities -- running anything is
    deferred for the program that did the import to invoke AFTER the import
    finished.
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
    Dennis Lee Bieber, 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:
    950
  2. per9000
    Replies:
    7
    Views:
    398
    Magnus Lycka
    Feb 27, 2006
  3. Bruce Sherwood

    A thread import problem

    Bruce Sherwood, Jul 19, 2012, in forum: Python
    Replies:
    0
    Views:
    150
    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:
    166
    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:
    139
    Dieter Maurer
    Jul 19, 2012
Loading...

Share This Page