Commit 19bdbc22 authored by Carlos Ramos Carreño's avatar Carlos Ramos Carreño Committed by Kazuhiko Shiozaki

Fixes the error in test_onErrorCallback.

The test testCMFActivity.TestCMFActivity.test_onErrorCallback was
failing because some weak references were not dropped.
The reason was that _DequeueMessageException was declared as global
and it kept a traceback including the variables pointed by the weak
references, preventing their garbage collection.
This was fixed by using a class for the _DequeueMessageException
instead of a singleton, and creating a new instance on every raise.
parent 737b9675
...@@ -83,7 +83,8 @@ def sort_message_key(message): ...@@ -83,7 +83,8 @@ def sort_message_key(message):
# same sort key as in SQLBase.getMessageList # same sort key as in SQLBase.getMessageList
return message.line.priority, message.line.date, message.uid return message.line.priority, message.line.date, message.uid
_DequeueMessageException = Exception() class _DequeueMessageException(Exception):
pass
_ITEMGETTER0 = operator.itemgetter(0) _ITEMGETTER0 = operator.itemgetter(0)
_IDENTITY = lambda x: x _IDENTITY = lambda x: x
...@@ -1011,11 +1012,11 @@ CREATE TABLE %s ( ...@@ -1011,11 +1012,11 @@ CREATE TABLE %s (
# increased. # increased.
for m in message_list: for m in message_list:
if m.getExecutionState() == MESSAGE_NOT_EXECUTED: if m.getExecutionState() == MESSAGE_NOT_EXECUTED:
raise _DequeueMessageException raise _DequeueMessageException()
transaction.commit() transaction.commit()
except: except:
exc_info = sys.exc_info() exc_info = sys.exc_info()
if exc_info[1] is not _DequeueMessageException: if not isinstance(exc_info[1], _DequeueMessageException):
self._log(WARNING, self._log(WARNING,
'Exception raised when invoking messages (uid, path, method_id) %r' 'Exception raised when invoking messages (uid, path, method_id) %r'
% [(m.uid, m.object_path, m.method_id) for m in message_list]) % [(m.uid, m.object_path, m.method_id) for m in message_list])
......
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