[Zope-CVS] CVS: Products/ExternalEditor - zopeedit.py:1.54
Chris McDonough
chrism at plope.com
Thu Mar 3 19:11:44 EST 2005
Update of /cvs-repository/Products/ExternalEditor
In directory cvs.zope.org:/tmp/cvs-serv32423
Modified Files:
zopeedit.py
Log Message:
Run through the loop one final time to catch modifications that are made *during* the isAlive call.
=== Products/ExternalEditor/zopeedit.py 1.53 => 1.54 ===
--- Products/ExternalEditor/zopeedit.py:1.53 Mon Jul 19 11:35:13 2004
+++ Products/ExternalEditor/zopeedit.py Thu Mar 3 19:11:44 2005
@@ -349,22 +349,34 @@
if use_locks:
self.lock()
+
+ final_loop = 0
while 1:
- editor.wait(save_interval or 2)
+ if not final_loop:
+ editor.wait(save_interval or 2)
+
mtime = os.path.getmtime(self.content_file)
-
- if (save_interval or not editor.isAlive()) and mtime != last_mtime:
- # File was modified
- launch_success = 1 # handle very short editing sessions
- self.saved = self.putChanges()
- last_mtime = mtime
- if editor.isAlive():
- launch_success = 1
- else:
- break
-
+ if mtime != last_mtime:
+ if save_interval or final_loop:
+ launch_success = 1 # handle very short editing sessions
+ self.saved = self.putChanges()
+ last_mtime = mtime
+
+ if not editor.isAlive():
+ if final_loop:
+ break
+ else:
+ # Go through the loop one final time for good measure.
+ # Our editor's isAlive method may itself *block* during a
+ # save operation (seen in COM calls, which seem to
+ # respond asynchronously until they don't) and subsequently
+ # return false, but the editor may have actually saved the
+ # file to disk while the call blocked. We want to catch
+ # any changes that happened during a blocking isAlive call.
+ final_loop = 1
+
if not launch_success:
fatalError('Editor did not launch properly.\n'
'External editor lost connection '
More information about the Zope-CVS
mailing list