CodeReclaimers / btce-api

Python wrapper around the public and trading APIs of BTC-e.com
MIT License
191 stars 123 forks source link

Best way to get around polling failure #36

Closed midnjerry closed 9 years ago

midnjerry commented 10 years ago

HI Alan,

This isn't an issue with your excellent api (or at least I haven't seen it), but what's the best way to capture exceptions and retry polling when you get 403 and SSL Errors?

Right now my bot is running on a batch file (in infinite loop) so python script can restart when any exceptions are caught.

I'm new to github and haven't figured out how to email you. :(

simlmx commented 10 years ago

I'm having similar infinite loop issues. Got around some by changing

self.conn.request("POST", url, params, headers)
response = self.conn.getresponse().read()

to

try:
    self.conn.request("POST", url, params, headers)
finally:
    response = self.conn.getresponse().read()

in common.py, but I still get some "[Errno 54] Connection reset by peer" on the self.conn.request("POST"..) line that break all subsequent calls to the same line...

simlmx commented 10 years ago

In the end I really got rid of the problem with: https://github.com/simlmx/btce-api/blob/51fad992e224f06b2d8df5348efb804ec6189026/btceapi/common.py#L137

CodeReclaimers commented 9 years ago

I apologize for the long absence, I'll apply simlmx's fix in the next week or so while I'm making some other updates.

CodeReclaimers commented 9 years ago

@simlmx thank you for coming up with a fix for this; I've included it in commit ed16a6835791a36220136e6626746737c3060cea.