python.exe/Tkinter hang on exit
Howard Lightstone
howard at eegsoftware.com
Fri Sep 7 01:06:27 EDT 2001
Mike Clarkson wrote:
> (.....cut)
> What version of Tk are you using?
>
I am using the Tk installed by Python2.0 (which I believe is 8.3)
>
> >It seems the application is hanging on OLESCELOCKMUTEX during
> >termination, thus leaving a zombie task (which...typically... means I
> >cannot shut Windows down gracefully, if such a thing were possible).
>
> What diagnostics are you using to detemine that it's a mutex hang?
> Can you tell which thread is hung - a running python.exe has 2 threads
> and loading Tkinter adds I think 3 more threads. The one that is
> steadily consuming CPU is probably the Tk mainloop. Can you tell if
> it's that one, one of the other threads started with Tk, or an
> original Python thread that gets locked?
There are several bugs related listed on the Sourceforge Python bug list:
#216289 and #453489
For that list, I ran the short test program in #453489 (12 lines, see below)
in both Pythonw and Python executables.
I used Taskinfo2000 to look at internals before/after termination.
Here is the data again:
Handles while running Python.exe (before quit)
|Handle||Type| |Refs||Name|
4 : Process 7 PID:FFF50719, C:\PYTHON20\PYTHON.EXE
8 : Console 3
C : Screen Buff 3
10 : Screen Buff 3
18 : Event 1
1C : Event 1
20 : Event 1
24 : Event 2
28 : Mutex 19 OLESCMLOCKMUTEX
2C : Event 1
30 : Event 1
34 : Thread 1 ThID:FFF79069, PID:FFF50719,
C:\PYTHON20\PYTHON.EXE
38 : Event 1
3C : Event 2
40 : Thread 1 ThID:FFF52B8D, PID:FFF50719,
C:\PYTHON20\PYTHON.EXE
44 : Event 1
48 : Event 2
4C : Thread 1 ThID:FFF53539, PID:FFF50719,
C:\PYTHON20\PYTHON.EXE
----------------------------------------------------------
Handles AFTER trying to quit
|Handle||Type| |Refs||Name|
4 : Process 4 PID:FFF50719, C:\PYTHON20\PYTHON.EXE
8 : Console 3
C : Screen Buff 3
10 : Screen Buff 3
18 : Event 1
1C : Event 1
20 : Event 1
24 : Event 1
28 : Mutex 19 OLESCMLOCKMUTEX
2C : Event 1
30 : Event 1
34 : Thread 1
38 : Event 1
3C : Event 1
40 : Thread 2 ThID:FFF52B8D, PID:FFF50719,
C:\PYTHON20\PYTHON.EXE
I *may* have been overeager to blame the ole mutex since there is also a
thread hanging.
>
>
> >I am assuming that some win32 thingey is not being called by the Tkinter
> >task temination logic, BUT, using pythonw.exe, termination ALWAYS
> >works correctly. (I am using Python 2.0)
>
> Can you post the Python code that your application uses to exit,
> including any wm_protocol calls you make to bind the x.
>
There is no special logic. Tkinter (if nothing else is assigned) binds to
the WM_DELETE_WINDOW message.
# bug 453489
from Tkinter import *
import sys
def foo():
print 'foo'
sys.stdout.flush()
root.deiconify()
print 'bar'
sys.stdout.flush()
root=Tk()
Button(root, text='Quit', command=root.quit).pack()
root.after(5000, foo)
root.mainloop()
>
> >Any clues? I haven't tried to take apart my apps and see which imports
> >do it
> >(but Pmw looks like just a wrapper) .
>
> It's a tough one, and it would be good to nail this one down.
>
> Mike.
I have been forced to put LOTS of print messages into my code, use some
methods to send sys.stdout/sys.syserr messages to a window, curse mightily,
and run pythonw only.....
More information about the Python-list
mailing list