[wingide-users] python shell and threads

Wingware Support support at wingware.com
Mon Oct 29 08:49:05 MDT 2007


Sebastian Fey wrote:
> if i evaluate the follwoing code in wingide´s python shell the thread is 
> not started.
> also if i pause debugging right before the last line (where the thread 
> is started) an try to start it manually in "debug-test" it is not started.
> also this is no I/O problem. the thread isnt started at all, i do not 
> just get no output from the thread.
> 
> thanks for your help,
> 
> Sebastian
> 
> import threading
> 
> class Test( threading.Thread ):
> 
> def __init__( self ):
> threading.Thread.__init__( self )
> 
> def run( self ):
> print "hello wingide"
> 
> if __name__ == "__main__":
> Test().start()

There are two issues here:

(1) In the shell, __name__ is not set to __main__, though it probably should be,

and

(2) the shell stops all threads whenever at the prompt so your thread doesn't
get run because of how the shell works (it's based on our debugger).

We decided not to fix (2) before 3.0 because of the potential for injecting
threading bugs when we add the necessary feature of allowing other threads
to run while one is stopped for "debugging".  In many cases, it makes more
sense to stop all threads when one is stopped, but this isn't always the
case and certainly the fact that the shell has inherited this behavior
is bad.

Thanks,

-- 

Stephan Deibel
Wingware | Python IDE
Advancing Software Development

www.wingware.com



More information about the wingide-users mailing list