Fix race-condition bug on upgrade

This commit is contained in:
Itay Mizeretz 2018-04-11 20:59:23 +03:00
parent be5d17ab42
commit 86d802882a
1 changed files with 6 additions and 1 deletions

View File

@ -91,7 +91,12 @@ def main():
if WormConfiguration.use_file_logging:
if os.path.exists(log_path):
os.remove(log_path)
# If log exists but can't be removed it means other monkey is running. This usually happens on upgrade
# from 32bit to 64bit monkey on Windows. In all cases this shouldn't be a problem.
try:
os.remove(log_path)
except OSError:
pass
LOG_CONFIG['handlers']['file']['filename'] = log_path
LOG_CONFIG['root']['handlers'].append('file')
else: