Commit 946451e1 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Fix bug in uses_commission decorator

Distinquish between exceptions in the decorated function and exceptions
in accepting/rejecting the commissions. The first one determines whether
serials should be accepted or rejected, while the second one is an error
indicating that commissioning can not be completed.
parent fd98e017
......@@ -138,15 +138,23 @@ def uses_commission(func):
try:
serials = []
ret = func(serials, *args, **kwargs)
except:
log.exception("Unexpected error")
try:
if serials:
reject_commission(serials=serials)
except:
log.exception("Exception while rejecting serials %s", serials)
raise
raise
# func has completed successfully. accept serials
try:
if serials:
accept_commission(serials)
return ret
except CallError:
log.exception("Unexpected error")
raise
except:
if serials:
reject_commission(serials=serials)
log.exception("Exception while accepting serials %s", serials)
raise
return wrapper
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment