Revision 5088
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/tnrs.py | ||
---|---|---|
13 | 13 |
max_pause = 600 # sec; = 10 min |
14 | 14 |
assert initial_pause <= max_pause |
15 | 15 |
max_taxons = 5000# according to http://tnrs.iplantcollaborative.org/TNRSapp.html |
16 |
max_tries = 5 |
|
16 | 17 |
|
17 | 18 |
# Protocol params |
18 | 19 |
url_base = 'http://tnrs.iplantcollaborative.org/tnrsdemo/' |
... | ... | |
123 | 124 |
response = urllib2.urlopen(urllib2.Request(csv_url)) |
124 | 125 |
debug_log('response info', str(response.info())) |
125 | 126 |
return response |
127 |
|
|
128 |
def repeated_tnrs_request(taxons, *args, **kw_args): |
|
129 |
for try_num in xrange(max_tries): |
|
130 |
try: return tnrs_request(taxons, *args, **kw_args) |
|
131 |
except InvalidResponse: pass # try again |
|
132 |
raise # error is not temporary |
Also available in: Unified diff
tnrs.py: Added repeated_tnrs_request() to retry a TNRS request which returned an invalid response