How could I implement a retry option within the PyCurl (libcurl) module in python? Something similar to the effect of:
curl --retry 3 --retry-delay 5 'http://somesite.com/somefile'
Current code:
buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://somesite.com/somefile')
with open('output.txt','w') as f:
c.setopt(c.WRITEFUNCTION, f.write)
c.perform()
Pycurl doesn't know how to re-initialize the consumer you supply through the
WRITEDATA
orWRITEFUNCTION
options, so your code has to implement the retry logic: