[Python-checkins] python/dist/src/Lib/plat-mac aetools.py,1.3,1.4

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
Fri, 28 Mar 2003 15:42:39 -0800


Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv27943

Modified Files:
	aetools.py 
Log Message:
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.


Index: aetools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/aetools.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** aetools.py	5 Mar 2003 21:16:06 -0000	1.3
--- aetools.py	28 Mar 2003 23:42:37 -0000	1.4
***************
*** 27,30 ****
--- 27,31 ----
  import MacOS
  import sys
+ import time
  
  from aetypes import *
***************
*** 33,36 ****
--- 34,40 ----
  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*....
***************
*** 175,178 ****
--- 179,190 ----
  		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):