DoEvents equiv?
Carlos Ribeiro
cribeiro at mail.inet.com.br
Wed May 9 20:12:42 EDT 2001
At 22:58 09/05/01 +0000, Mark Hammond wrote:
>Carlos Ribeiro wrote:
>>Mark, don't you think that it would make sense for the Python interpreter
>>to have some option to call PumpMessages internally from time to time?
>>It's part of being a good citizen of Windowsland. I was wondering if it
>>is possible to make a call from inside the interpreter, yielding control
>>back to Windows periodically.
>
>As I mentioned, it depends on the GUI system. I dont know how Python
>could implement this so it works with MFC, Win32GUI, wxPython and Tkinter apps.
I'm not an expert on this issue, but, as far as I know, it doesn't depend
on the GUI system. It's just a matter of calling PumpMessages, from the
Win32 library. All Win32 applications should honor this call. I'll
double-check it. (I know that there may be problems with reentrancy - more
on this later).
>Also, I don't see the value in added complexity just to save you one line
>in your code.
Mark, it's not lazyness. The problem is that you can't just put it in a
single line of code. You have to scatter calls to
pythoncom.PumpWaitingMessages all over the place, specially if you are
doing something more complex. And using threads just for this is overkill.
Also, note that this call is not available under Linux, so you have to take
this in account also (test the os, load pythoncom only on Win32...).
As for the reentrancy problems, yes, it may happen. I don't know the
current state of win32ui, wxPython and Tkinter on this respect. This needs
some checking, but I believe that many problems may be avoided by
techniques of message queueing on the main event loop. At least, the host
application (PythonWin, in my case) could receive its messages.
And, last, but not least: this problem affects specially non-windows
applications. Sometimes I'm bitten by a misterious bug in the middle of a
long log processing script, and I have nothing to do, but Ctrl-Alt-Del and
finalize PythonWin. Pity. In Linux, at least the Ctrl-C is honored.
Carlos Ribeiro
More information about the Python-list
mailing list