DoEvents equiv?

Carlos Ribeiro cribeiro at mail.inet.com.br
Wed May 9 10:22:11 EDT 2001


At 12:50 09/05/01 +0000, Mark Hammond wrote:
>It really depends on the GUI system you are running.  In many cases, 
>PumpMessages in either win32ui, win32gui or pythoncom will do the job. For 
>a Tkinter app, it will be something different, but I don't know what that is.

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.

In resume, the idea is:

- *In the Win32 platform*, add an *optional* feature, turned *on* by 
default, to yield control back to Windows.
- In the implementation, the PumpMessages() call could be done inside the 
interpreter, at every n opcodes parsed. The implementation can be done in a 
simple and efficient fashion. A simple int counter, starting from the max 
value down to zero; when it reaches zero, call PumpMessages and start over.
- The opcode counter limit setting could even be customized by the command 
line option (shorter values make the system more responsive, but have a 
performance hit).

This would bring some benefits. I work with some scripts that read long 
text files, and sometimes it does take a few minutes to finish processing. 
Sometimes I just can't break into the code. Sometimes the activate or break 
options of PythonWin (on the systray) are not enough, because the 
intepreter simply does not help. I noticed that PythonWin 210 is a little 
bit more responsive, but the problem still happens from time to time.

Of course, this does not stop code from inside C libraries from locking, 
but that's another issue.


Carlos Ribeiro






More information about the Python-list mailing list