Commit 86fb6276 authored by Jérome Perrin's avatar Jérome Perrin

sys.exc_info()[0] can be the error for the try: except inside the big except: clause.

store the exception in a variable to make sure we have the right one.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13550 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d7922120
...@@ -305,7 +305,7 @@ class SQLDict(RAMDict): ...@@ -305,7 +305,7 @@ class SQLDict(RAMDict):
break break
else: else:
get_transaction().abort() get_transaction().abort()
except: except Exception, exc:
# If an exception occurs, abort the transaction to minimize the impact, # If an exception occurs, abort the transaction to minimize the impact,
try: try:
get_transaction().abort() get_transaction().abort()
...@@ -313,7 +313,7 @@ class SQLDict(RAMDict): ...@@ -313,7 +313,7 @@ class SQLDict(RAMDict):
# Unfortunately, database adapters may raise an exception against abort. # Unfortunately, database adapters may raise an exception against abort.
LOG('SQLDict', WARNING, 'abort failed, thus some objects may be modified accidentally') LOG('SQLDict', WARNING, 'abort failed, thus some objects may be modified accidentally')
pass pass
if issubclass(sys.exc_info()[0], ConflictError): if issubclass(exc, ConflictError):
# For a conflict error, simply delay the operations. # For a conflict error, simply delay the operations.
for uid_list in uid_list_list: for uid_list in uid_list_list:
if len(uid_list): if len(uid_list):
......
...@@ -125,7 +125,7 @@ class SQLQueue(RAMQueue): ...@@ -125,7 +125,7 @@ class SQLQueue(RAMQueue):
activity_tool.invoke(m) # Try to invoke the message activity_tool.invoke(m) # Try to invoke the message
if m.is_executed: # Make sure message could be invoked if m.is_executed: # Make sure message could be invoked
get_transaction().commit() # If successful, commit get_transaction().commit() # If successful, commit
except: except Exception, exc:
# If an exception occurs, abort the transaction to minimize the impact, # If an exception occurs, abort the transaction to minimize the impact,
try: try:
get_transaction().abort() get_transaction().abort()
...@@ -134,7 +134,7 @@ class SQLQueue(RAMQueue): ...@@ -134,7 +134,7 @@ class SQLQueue(RAMQueue):
LOG('SQLQueue', WARNING, 'abort failed, thus some objects may be modified accidentally') LOG('SQLQueue', WARNING, 'abort failed, thus some objects may be modified accidentally')
pass pass
if issubclass(sys.exc_info()[0], ConflictError): if issubclass(exc, ConflictError):
# If a conflict occurs, delay the operation. # If a conflict occurs, delay the operation.
activity_tool.SQLQueue_setPriority(uid = line.uid, date = next_processing_date, activity_tool.SQLQueue_setPriority(uid = line.uid, date = next_processing_date,
priority = line.priority) priority = line.priority)
......
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