diff options
author | Alistair Coles <alistair.coles@hp.com> | 2014-10-09 09:42:16 +0100 |
---|---|---|
committer | Alistair Coles <alistair.coles@hp.com> | 2014-10-20 08:58:19 +0100 |
commit | 43c1141baa6c5a5987fd4ab71d1c2299898ea251 (patch) | |
tree | 8753a6572122eeec90f45142308aabbc55430dc9 /swiftclient/shell.py | |
parent | 589d34ecda7ebec3726ad4181306d3ec9e69bf9d (diff) | |
download | python-swiftclient-43c1141baa6c5a5987fd4ab71d1c2299898ea251.tar.gz |
Fix race in shell when testing for errors to raise SysExit
SysExit is raised if the OutputManager has non-zero
error_count. However, error_count is incremented in
a print thread, but tested on the main thread.
Currently error_count is tested before the OutputManager
print threads have exited, which results in a race. This race
means that SysExit is not always raised even when an error
has occured.
This change moves the error_count test after the
OutputManager context manager has exited, which ensures that
the OutputManager threads have exited.
Change-Id: I5ef7d9f10057fe2b41f48ab95066a7265b86a3ac
Closes-Bug: #1379229
Diffstat (limited to 'swiftclient/shell.py')
-rwxr-xr-x | swiftclient/shell.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/swiftclient/shell.py b/swiftclient/shell.py index 07a7e52..619ec5c 100755 --- a/swiftclient/shell.py +++ b/swiftclient/shell.py @@ -1304,9 +1304,7 @@ Examples: except (ClientException, RequestException, socket.error) as err: output.error(str(err)) - had_error = output.error_count > 0 - - if had_error: + if output.error_count > 0: exit(1) |