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
=== modified file 'summit/schedule/models/summitmodel.py'
--- summit/schedule/models/summitmodel.py 2011-04-29 16:04:00 +0000
+++ summit/schedule/models/summitmodel.py 2011-06-10 12:23:41 +0000
@@ -15,6 +15,8 @@
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17import pytz17import pytz
18import sys
19import time
18import urllib220import urllib2
1921
20from datetime import datetime22from datetime import datetime
@@ -160,7 +162,20 @@
160 """Update from Launchpad data."""162 """Update from Launchpad data."""
161 url = ("https://launchpad.net/sprints/%s/+temp-meeting-export"163 url = ("https://launchpad.net/sprints/%s/+temp-meeting-export"
162 % self.name)164 % self.name)
163 export = urllib2.urlopen(url)165 trycounter = 0
166 retrytotal = 5
167 while trycounter <= retrytotal:
168 try:
169 export = urllib2.urlopen(url)
170 except urllib2.HTTPError, e:
171 trycounter += 1
172 if trycounter >= retrytotal:
173 print "Error while calling the launchpad API: " + str(e)
174 sys.exit(1)
175 else:
176 time.sleep(2)
177 else:
178 break
164 tree = ElementTree.parse(export)179 tree = ElementTree.parse(export)
165180
166 for elem in tree.find("attendees").findall("person"):181 for elem in tree.find("attendees").findall("person"):

Subscribers

People subscribed via source and target branches