Deadlocking IDLE under Win32

Mark Hammond mhammond at skippinet.com.au
Wed Apr 12 02:19:20 CEST 2000


My guess is that the "print" under IDLE is not thread-safe.  Change the
program to not print (or to append items to a queue, which the main thread
then prints) and see if this is the problem.

If so, consider submitting a patch to IDLE.  In Pythonwin, the
sys.stdout.write function checks if it is the main thread, and if not
simply queues the output (module Queue) for the main thread to print.

[This may also explain why I see the threading test hang when running the
Python test suite under IDLE]

Mark.

"James "Wez" Weatherall" <jnw22 at cam.ac.uk> wrote in message
news:8cuudo$8pj$1 at pegasus.csx.cam.ac.uk...
> I've noticed a bug with which a simple multithreaded test program such
as:
>
> import threading
>
> class MyThread(threading.Thread):
>     def run(self):
>         while self.a < 1000:
>             print self.a,
>             self.a=self.a+2
>
> thread1=MyThread()
> thread2=MyThread()
> thread1.a, thread2.a = 0, 1
> thread1.start()
> thread2.start()
>
> This program will print out about twenty numbers and then hang the whole
> interpreter if you run it from IDLE but it runs fine from the
command-line
> version, suggesting some locking problem in the Tk-based print command.
>
> Does anyone have any ideas about this?
>
> Cheers,
>
> --
> James "Wez" Weatherall
>
>
>





More information about the Python-list mailing list