Merge lp:~pendulum/summit/665589-launchpad-request-retries into lp:summit

Proposed by Penelope Stowe
Status: Merged
Approved by: Nigel Babu
Approved revision: 120
Merged at revision: 119
Proposed branch: lp:~pendulum/summit/665589-launchpad-request-retries
Merge into: lp:summit
Diff against target: 34 lines (+16/-1)
1 file modified
summit/schedule/models/summitmodel.py (+16/-1)
To merge this branch: bzr merge lp:~pendulum/summit/665589-launchpad-request-retries
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Nigel Babu (community) Approve
Review via email: mp+63845@code.launchpad.net

Commit message

try-catching the launchpad requests with 5 retries

Description of the change

try-catching the launchpad requests with 5 retries

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi Penelope,

Thanks for the branch, it will be a useful feature.

18 + trycounter = 0
19 + retrytotal = 5

The trycounter line needs an extra space at the front to line up.

26 + print "Error while calling the launchpad API"

It would be useful to see the error that came back from launchpad here
when debugging. You can do this by changing

23 + except urllib2.HTTPError:

to be

23 + except urllib2.HTTPError, e:

and then putting "+ str(e)" at the end of the print line, adjusting the current
error message to have ": " at the end to stop the two parts running in to each
other.

Thanks,

James

review: Needs Fixing
118. By Penelope Stowe

Fixed formatting and added error information

119. By Penelope Stowe

More format fixing.

120. By Penelope Stowe

Got the error message to actually display

Revision history for this message
Nigel Babu (nigelbabu) wrote :

Thanks so much for your patience in fixing the small small things. This now looks good to go :-)

review: Approve
Revision history for this message
James Westby (james-w) wrote :

Looks great! Thanks for the fix.

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'summit/schedule/models/summitmodel.py'
2--- summit/schedule/models/summitmodel.py 2011-04-29 16:04:00 +0000
3+++ summit/schedule/models/summitmodel.py 2011-06-10 12:23:41 +0000
4@@ -15,6 +15,8 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6
7 import pytz
8+import sys
9+import time
10 import urllib2
11
12 from datetime import datetime
13@@ -160,7 +162,20 @@
14 """Update from Launchpad data."""
15 url = ("https://launchpad.net/sprints/%s/+temp-meeting-export"
16 % self.name)
17- export = urllib2.urlopen(url)
18+ trycounter = 0
19+ retrytotal = 5
20+ while trycounter <= retrytotal:
21+ try:
22+ export = urllib2.urlopen(url)
23+ except urllib2.HTTPError, e:
24+ trycounter += 1
25+ if trycounter >= retrytotal:
26+ print "Error while calling the launchpad API: " + str(e)
27+ sys.exit(1)
28+ else:
29+ time.sleep(2)
30+ else:
31+ break
32 tree = ElementTree.parse(export)
33
34 for elem in tree.find("attendees").findall("person"):

Subscribers

People subscribed via source and target branches