Commit f2bea116 authored by Jérome Perrin's avatar Jérome Perrin

ProcessingNodeTestCase.tic: fail as soon as one message had failed

Now that tic retries until the deadline is reached or all messages has
failed, it can lead to situations where developer have to wait until the
deadline, when a message failed but other messages (typically scheduled
to run after the failed message) were still running.

By stopping as soon as one message is failed, in this scenario the
developer does not need to wait until the deadline.
parent aa7ae8b5
......@@ -269,8 +269,21 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
transaction.commit()
self.abort()
def tic(self, verbose=0, stop_condition=lambda message_list: False, delay=600):
"""Execute pending activities"""
def tic(self, verbose=0, stop_condition=lambda message_list: False, delay=10*60):
"""Execute pending activities.
This method executes activities until all messages are executed successfully,
or at least execution of one message was marked as failed, in this case a
RuntimeError exception will be raised.
`stop_condition` can be a function that will be called between each iteration
with the list of pending messages and return True to stop execution, or False
to continue.
If the total time spent processing activities exceeded `delay` seconds (default
10 minutes), then the processing is interrupted and `tic` raise a RuntimeError
exception.
"""
transaction.commit()
# Some tests like testDeferredStyle require that we use self.getPortal()
# instead of self.portal in order to setup current skin.
......@@ -296,7 +309,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
raise KeyboardInterrupt
message_list = getMessageList()
message_count = len(message_list)
if time.time() >= deadline or message_count and all(x.processing_node == -2
if time.time() >= deadline or message_count and any(x.processing_node == -2
for x in message_list):
# We're about to raise RuntimeError, but maybe we've reached
# the stop condition, so check just once more:
......
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