I'm having a problem with my program freezing, I think it is due to no connection to the Poloniex server. How do I keep looping the urlopen
request until a connection is established?
Here is what I have:
elif(command == "returnOrderBook"):
try:
ret = urllib2.urlopen(urllib2.Request('https://poloniex.com/public?command=' + command + '¤cyPair=' + str(req['currencyPair'])))
return json.loads(ret.read())
except:
print('no connection')
else: return None
And in the main:
jsn = None
count = 0;
for pair in pairs:
while(jsn == None):
jsn = p.returnMarketTradeHistory (pair)
if(jsn == None):
print('jsn failed')
sleep(0.3)
I have checked the timings and I don't seem to be breaking any excessive data request limits from Poloniex.