Merge lp:~spiv/wrested/deferred-semaphore-tweak into lp:wrested

Proposed by Andrew Bennetts
Status: Merged
Merged at revision: 31
Proposed branch: lp:~spiv/wrested/deferred-semaphore-tweak
Merge into: lp:wrested
Diff against target: 22 lines (+2/-11)
1 file modified
wrested/__init__.py (+2/-11)
To merge this branch: bzr merge lp:~spiv/wrested/deferred-semaphore-tweak
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+57035@code.launchpad.net

Description of the change

The intended API for DeferredSemaphore is to call its 'run' method, rather than acquire/release manually.

This is a quick untested tweak to do so.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

great, thankyou

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'wrested/__init__.py'
2--- wrested/__init__.py 2011-03-05 02:37:10 +0000
3+++ wrested/__init__.py 2011-04-09 02:25:46 +0000
4@@ -70,17 +70,8 @@
5 :returns: Deferred producing (response_metadata, body).
6 """
7 # print 'queue get of url %s' % url
8- def release(result):
9- self.throttle_semaphore.release()
10- return result
11- def can_proceed(ignored):
12- # print 'get url %s' % url
13- d = self.browser.get(url,
14- headers={'User-agent': 'wrested/0'})
15- d.addBoth(release)
16- return d
17- d = self.throttle_semaphore.acquire()
18- d.addCallback(can_proceed)
19+ d = self.throttle_semaphore.run(
20+ self.browser.get, url, headers={'User-agent': 'wrested/0'})
21 d.addErrback(self.on_http_failure, url)
22 return d
23

Subscribers

People subscribed via source and target branches

to all changes: