I am trying to understand how to handle a http.client.IncompleteRead Error in the code below. I handle the error using the idea in this post. Basically, I thought it might just be the server limiting the number of times I can access the data, but strangely I get a HTTP Status Code of 200 sometimes, but still the code below ends up returning a None type. Is this because zipdata = e.partial is not returning anything when the Error comes up?
def update(self, ABBRV):
    if self.ABBRV == 'cd':
        try:
            my_url = 'http://www.bankofcanada.ca/stats/results/csv'
            data = urllib.parse.urlencode({"lookupPage": "lookup_yield_curve.php",
                                 "startRange": "1986-01-01",
                                 "searchRange": "all"})
            binary_data = data.encode('utf-8')
            req = urllib.request.Request(my_url, binary_data)
            result = urllib.request.urlopen(req)
            print('status:: {},{}'.format(result.status, my_url))
            zipdata = result.read()
            zipfile = ZipFile(BytesIO(zipdata))
            df = pd.read_csv(zipfile.open(zipfile.namelist()[0]))
            df = pd.melt(df, id_vars=['Date'])
            return df
        #In case of http.client.IncompleteRead Error
        except http.client.IncompleteRead as e:
            zipdata = e.partial
Thank You
 
     
     
    