From: Jack Jansen Date: Fri, 28 Mar 2003 23:42:37 +0000 (+0000) Subject: On OSX the finder will return from an open() event before the application X-Git-Tag: v2.3c1~1342 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d6ab153e5a715e409010e62d3214f848aa7339ed;p=thirdparty%2FPython%2Fcpython.git On OSX the finder will return from an open() event before the application has actually entered its event loop. As a stopgap, allow for a 10 second grace period. --- diff --git a/Lib/plat-mac/aetools.py b/Lib/plat-mac/aetools.py index 8ac293d642d3..06395416a6cd 100644 --- a/Lib/plat-mac/aetools.py +++ b/Lib/plat-mac/aetools.py @@ -26,12 +26,16 @@ from Carbon import AE from Carbon import AppleEvents import MacOS import sys +import time from aetypes import * from aepack import packkey, pack, unpack, coerce, AEDescType Error = 'aetools.Error' +# Amount of time to wait for program to be launched +LAUNCH_MAX_WAIT_TIME=10 + # Special code to unpack an AppleEvent (which is *not* a disguised record!) # Note by Jack: No??!? If I read the docs correctly it *is*.... @@ -174,6 +178,14 @@ class TalkTo: self.send('ascr', 'noop') except AE.Error: _launch(self.target_signature) + for i in range(LAUNCH_MAX_WAIT_TIME): + try: + self.send('ascr', 'noop') + except AE.Error: + pass + else: + break + time.sleep(1) def start(self): """Deprecated, used _start()"""