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


Groups > comp.lang.python > #25828 > unrolled thread

Re: A thread import problem

Started byBruce Sherwood <bruce.sherwood@gmail.com>
First post2012-07-22 13:04 -0600
Last post2012-07-22 13:04 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: A thread import problem Bruce Sherwood <bruce.sherwood@gmail.com> - 2012-07-22 13:04 -0600

#25828 — Re: A thread import problem

FromBruce Sherwood <bruce.sherwood@gmail.com>
Date2012-07-22 13:04 -0600
SubjectRe: A thread import problem
Message-ID<mailman.2438.1342983873.4697.python-list@python.org>
On Sat, Jul 21, 2012 at 5:47 PM, Dennis Lee Bieber
<wlfraed@ix.netcom.com> wrote:
> On Sat, 21 Jul 2012 17:10:05 -0600, Bruce Sherwood
> <bruce.sherwood@gmail.com> 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
>         wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/
>
> --
> http://mail.python.org/mailman/listinfo/python-list

I don't have the luxury of doing things the "approved" way. I'm
constrained by extensive legacy code (and legacy educational
documentation for student use) to be able to run programs such as this
one:

from visual import box
b = box()
while True:
     b.pos.x += 0.001

Another way of saying this is that I'm not building an app, in which
case I would structure things in a simple and straightforward manner.
I am instead trying to maintain and update a library that allows
novice programmers to write programs that generate real-time navigable
3D animations, writing minimalist programs that work cross-platform.

Bruce Sherwood

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web