Chromium Code Reviews| 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 |
| + |