From 2d8813b06c737ca91ed841124226c3abbf1e66a1 Mon Sep 17 00:00:00 2001 From: Aaron Helsinger Date: Wed, 20 May 2015 09:29:10 -0400 Subject: [PATCH] ticket #824: If we get an OS error doing os.rename of stitcher.log and it is the text windows gives when the file is in use, then exit with a more helpful error message. --- CHANGES | 2 ++ src/stitcher.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index cb9db772..69572d8d 100644 --- a/CHANGES +++ b/CHANGES @@ -90,6 +90,8 @@ gcf 2.9: * Bug fix for merging comments when template has a comment child and other does not. (#815) * Quiet down errors deleting a failed reservation from EG AMs (harmless). (#811) * Remove reference to ION as a real aggregate in the README. ION has been decommissioned. (#797) + * Gracefully handle error when 2 stitcher instances are running in the same directory + at once on Windows. (#824) * Scripts * Initial commit of `examples/renewSliceAndSlivers.py`. (#798) diff --git a/src/stitcher.py b/src/stitcher.py index 8b2d7f4d..36000eb8 100755 --- a/src/stitcher.py +++ b/src/stitcher.py @@ -304,7 +304,16 @@ def call(argv, options=None): if os.path.exists(dfn): os.remove(dfn) if os.path.exists(bfn): - os.rename(bfn, dfn) + try: + os.rename(bfn, dfn) + except OSError, e: + # Issue #824 partial solution + if "being used by another process" in str(e): + # On Windows, when another stitcher instance running in same directory, so has stitcher.log open + # WindowsError: [Error 32] The process cannot access the file because it is being used by another process + sys.exit("Error: Is another stitcher process running in this directory? Run stitcher from a different directory, or re-run with the option `--fileDir `") + else: + raise # Then have Omni configure the logger try: