Skip to content

Commit

Permalink
added exception handling for examples/py/async-gdax-fetch-ticker-cont…
Browse files Browse the repository at this point in the history
…inuously.py fix #3021
  • Loading branch information
kroitor committed Jun 3, 2018
1 parent 30b27e2 commit f7eb169
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions examples/py/async-gdax-fetch-ticker-continuously.py
Expand Up @@ -15,9 +15,26 @@ async def main(exchange, symbol):
print('--------------------------------------------------------------')
print(exchange.iso8601(exchange.milliseconds()), 'fetching', symbol, 'ticker from', exchange.name)
# this can be any call instead of fetch_ticker, really
ticker = await exchange.fetch_ticker(symbol)
print(exchange.iso8601(exchange.milliseconds()), 'fetched', symbol, 'ticker from', exchange.name)
print(ticker)
try:
ticker = await exchange.fetch_ticker(symbol)
print(exchange.iso8601(exchange.milliseconds()), 'fetched', symbol, 'ticker from', exchange.name)
print(ticker)
except ccxt.RequestTimeout as e:
print('[' + type(e).__name__ + ']')
print(str(e)[0:200])
# will retry
except ccxt.DDoSProtection as e:
print('[' + type(e).__name__ + ']')
print(str(e.args)[0:200])
# will retry
except ccxt.ExchangeNotAvailable as e:
print('[' + type(e).__name__ + ']')
print(str(e.args)[0:200])
# will retry
except ccxt.ExchangeError as e:
print('[' + type(e).__name__ + ']')
print(str(e)[0:200])
break # won't retry


# you can set enableRateLimit = True to enable the built-in rate limiter
Expand Down

0 comments on commit f7eb169

Please sign in to comment.