Merge lp:~free.ekanayaka/storm/track-retries into lp:storm

Proposed by Free Ekanayaka
Status: Merged
Approved by: Björn Tillenius
Approved revision: 428
Merge reported by: Free Ekanayaka
Merged at revision: not available
Proposed branch: lp:~free.ekanayaka/storm/track-retries
Merge into: lp:storm
Diff against target: 0 lines
To merge this branch: bzr merge lp:~free.ekanayaka/storm/track-retries
Reviewer Review Type Date Requested Status
Björn Tillenius (community) Approve
Thomas Herve (community) Approve
Review via email: mp+83956@code.launchpad.net

Description of the change

This branch adds a new on_retry instance variable to the storm.twisted.Transactor, which can be set to a function that will be called back just before executing a retry.

To post a comment you must log in.
427. By Free Ekanayaka

Call transaction.begin() at each try iteration

428. By Free Ekanayaka

Reverted the transaction.begin() change for now, because it causes uncommitted test data to be lost

Revision history for this message
Thomas Herve (therve) wrote :

+1!

review: Approve
Revision history for this message
Björn Tillenius (bjornt) wrote :

[1]

+class RetryContext(object):
+ """Hold details about a function that is going to be retried.
+
+ @ivar function: The function that is going to be retried.
+ @ivar args: The positional arguments passed to the function.
+ @ivar kwargs: The keyword arguments passed to the function.
+ @ivar retry: The sequential number of the retry that is going to be
+ performed.
+ """

Wouldn't it make sense to include the error that caused the retry to happen?

[2]

+ sleep = time.sleep
+ uniform = random.uniform

Using methods on Transactor makes sense, in order to reduce the need of mocking. However, I see that in the tests you still mock these methods. Unless the tests are explicitly testing, asserting that those methods are called the right amount of times just adds noise to the test. So I'd say that unless you mention the sleep behavior in the test docstring, don't mock them. Better to have a separate test that tests the sleep behavior.

review: Approve
429. By Free Ekanayaka

Include the error in RetryContext

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Thanks!

[1] Fixed

[2] As discussed, these tests were already there and I didn't want to change them. Also, they do check that sleep() and random() are called in a certain order and with certain arguments.

Preview Diff

Empty

Subscribers

People subscribed via source and target branches

to status/vote changes: