[PYTHONMAC-SIG] apps freeze unless they print!

Bill Bedford billpy@mail.demon.net
Mon, 19 May 1997 12:01:35 +0100

At 10:07 pm +0100 18/05/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.

Not quite true, replace the print line with

if t % 10 == 0:print t

and then have some patience when you bring the consol to the front.
You will see after 10 secs a new entry, then after another 10 secs a second
new entries and then after a further 10sec there will be a redraw and all
the entries will appear.
~Perhaps the Mac guts are only being updated whenever the console window is
~updated.  But I don't really want to clutter up my nice log window with
~useless garbage (and system.out.write('') doesn't work either, I tried
~it!).  Is there any other way to trigger the Mac event-handling parts?

The Mac guts are being up dated, but you are putting null events into the
console's event queue and these are having to time out before it redraws.

One way round would be to use MacOS.SetScheduleTimes() to make the console
check the event queue more often and so speed up the redraw.

 Bill Bedford                                  Designer of Photo-Etches

               owner Brit_Rail-L  ---  british railways historical list


PYTHONMAC-SIG  - SIG on Python for the Apple Macintosh

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