[PYTHONMAC-SIG] apps freeze unless they print!

Just van Rossum just@knoware.nl
Mon, 19 May 1997 00:24:28 +0200

At 2:07 PM 5/18/97, Joseph J. Strout wrote:
>I'm suddenly finding that Python locks up under the following conditions: I
>have a program in a loop which is working very hard (or snoozing) for a
>long time without printing anything to the console window (sample code
>below); I switch to the Finder or any other app; then I switch back --
>presto, it's frozen.  By "frozen" I mean that the window is not refreshed,
>I can't move it, and I can't switch back to the Finder or any other app; I
>have to hit command-period or kill the Python process.

Hm, I'm not getting exactly the same what you describe. My window does not
get updated, but I can move it and I can go back and forth between apps no
The not updating thing is annoying indeed. I found the reason in macglue.c:

** We have to be careful, since we can't handle
** things like updates (and they'll keep coming back if we don't
** handle them). Note that we don't know who has windows open, so
** even handing updates off to SIOUX under MW isn't going to work.
#define MAINLOOP_EVENTMASK (mDownMask|keyDownMask|osMask)

Can't we check whether there are custom windows? Say, disable update events
as soon as Win.GetNewWindow() and relatives are used? Hmm, not "safe" when
a C-extension makes it's own windows. But then again, then you're probably
running a custom event loop already. I'd say, if the Appswitching var has
the default value (1), there's only small chance there are any other
windows open besides SIOUX.
Perhaps a new option for MacOS.EnableAppswitch()? So, if you want updates
to be handled correctly while a script is running, do
MacOS.EnableAppswitch(2). It couldn't be turned on by default I think.
I wish I could do Appswitching while a script is running in a FrameWork
environment (with all event handling done in Python), but I think we need
thread support to do that...


PYTHONMAC-SIG  - SIG on Python for the Apple Macintosh

send messages to: pythonmac-sig@python.org
administrivia to: pythonmac-sig-request@python.org