Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: tools/dom/scripts/multiemitter.py

Issue 18676003: Make multiple attempts to write binding files to disc (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/multiemitter.py
diff --git a/tools/dom/scripts/multiemitter.py b/tools/dom/scripts/multiemitter.py
index 78d552b48e96b2315df8e0c630646131ced13756..2e9922c92376369ce15c040383580c6dccbf98dc 100644
--- a/tools/dom/scripts/multiemitter.py
+++ b/tools/dom/scripts/multiemitter.py
@@ -6,9 +6,9 @@
"""Templating to help generate structured text."""
import os
-import re
kustermann 2013/07/04 11:54:16 "re" was unused
import sys
import subprocess
+import time
import emitter
import logging
@@ -85,24 +85,33 @@ def _WriteFile(path, lines):
_logger.info('Warning: File still exists- %s' % path)
# Write the file.
- try:
- _logger.info('Writing - %s' % path)
- f = open(path, 'w')
- f.writelines(lines)
- f.close()
- except IOError as error:
- # FIXME(kustermann): Remove this later on.
- # We try to get more debugging information to figure out why we sometimes
- # get a "Permission denied" error when opening the file for writing.
- # (hypothesis: Another process has already opened the file.)
- _logger.info('Got exception (%s) ' % error)
-
- if sys.platform == 'win32':
- handle_file = r'E:\handle.exe'
- if os.path.exists(handle_file):
- _logger.info('Running handle.exe for debugging purposes')
- subprocess.call([handle_file, '-a', r'E:\b\build\slave'])
+ num_attempts = 4
+ for i in range(num_attempts):
+ try:
+ _logger.info('Writing (attempt %d) - %s' % (i + 1, path))
+ f = open(path, 'w')
+ f.writelines(lines)
+ f.close()
+ return
+ except IOError as error:
+ last_attempt = (i == (num_attempts - 1))
+ if not last_attempt:
+ # Sleep for 50 ms and try again
+ time.sleep(0.05)
else:
- _logger.info("Couldn't find %s. Not printing open handles."
- % handle_file)
- raise error
+ # FIXME(kustermann): Remove this later on.
+ # We try to get more debugging information to figure out why we
+ # sometimes get a "Permission denied" error when opening the file for
+ # writing. (hypothesis: Another process has already opened the file.)
+ _logger.info('Got exception (%s) ' % error)
+
+ if sys.platform == 'win32':
+ handle_file = r'E:\handle.exe'
+ if os.path.exists(handle_file):
+ _logger.info('Running handle.exe for debugging purposes')
+ subprocess.call([handle_file, '-a', r'E:\b\build\slave'])
+ else:
+ _logger.info("Couldn't find %s. Not printing open handles."
+ % handle_file)
+ raise error
+
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698