sammchardy / python-idex

IDEX v3 Exchange REST API python implementation

Home Page:https://python-idex.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hangs nondeterministically on calls

clu8 opened this issue · comments

Hi, it appears that on all calls such as to get_tickers, there is a small chance that the client hangs forever. Maybe a timeout should be added?

Sorry, I misspoke. Doesn't look like it hangs indefinitely, but it hangs a very long time. Example exception:

IdexAPIException: IdexAPIException: b'<!DOCTYPE html>\n<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->\n<!--[if IE 7]>    <html class="n
o-js ie7 oldie" lang="en-US"> <![endif]-->\n<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->\n<!--[if gt IE 8]><!--> <html class="no-js"
lang="en-US"> <!--<![endif]-->\n<head>\n<meta http-equiv="refresh" content="0">\n\n<title>api.idex.market | 524: A timeout occurred</title>\n<meta charset="UTF-8"
/>\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />\n<meta name="robots" co
ntent="noindex, nofollow" />\n<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />\n<link rel="stylesheet" id="cf_styles-css" href
="/cdn-cgi/styles/cf.errors.css" type="text/css" media="screen,projection" />\n<!--[if lt IE 9]><link rel="stylesheet" id=\'cf_styles-ie-css\' href="/cdn-cgi/style
s/cf.errors.ie.css" type="text/css" media="screen,projection" /><![endif]-->\n<style type="text/css">body{margin:0;padding:0}</style>\n\n\n\n\n</head>\n<body>\n<di
v id="cf-wrapper">\n\n    \n\n    <div id="cf-error-details" class="cf-error-details-wrapper">\n        <div class="cf-wrapper cf-error-overview">\n            <h1
>\n              \n              <span class="cf-error-type">Error</span>\n              <span class="cf-error-code">524</span>\n              <small class="headin
g-ray-id">Ray ID: 446cc5353b272a67 &bull; 2018-08-07 21:19:09 UTC</small>\n            </h1>\n            <h2 class="cf-subheadline">A timeout occurred</h2>\n
   </div><!-- /.error-overview -->\n        \n        <div class="cf-section cf-highlight cf-status-display">\n            <div class="cf-wrapper">\n
  <div class="cf-columns cols-3">\n                  \n<div id="cf-browser-status" class="cf-column cf-status-item cf-browser-status ">\n  <div class="cf-icon-erro
r-container">\n    <i class="cf-icon cf-icon-browser"></i>\n    <i class="cf-icon-status cf-icon-ok"></i>\n  </div>\n  <span class="cf-status-desc">You</span>\n  <
h3 class="cf-status-name">Browser</h3>\n  <span class="cf-status-label">Working</span>\n</div>\n\n<div id="cf-cloudflare-status" class="cf-column cf-status-item cf
-cloudflare-status ">\n  <div class="cf-icon-error-container">\n    <i class="cf-icon cf-icon-cloud"></i>\n    <i class="cf-icon-status cf-icon-ok"></i>\n  </div>\
n  <span class="cf-status-desc">Seattle</span>\n  <h3 class="cf-status-name">Cloudflare</h3>\n  <span class="cf-status-label">Working</span>\n</div>\n\n<div id="cf
-host-status" class="cf-column cf-status-item cf-host-status cf-error-source">\n  <div class="cf-icon-error-container">\n    <i class="cf-icon cf-icon-server"></i>
\n    <i class="cf-icon-status cf-icon-error"></i>\n  </div>\n  <span class="cf-status-desc">api.idex.market</span>\n  <h3 class="cf-status-name">Host</h3>\n  <spa
n class="cf-status-label">Error</span>\n</div>\n\n                </div>\n              \n            </div>\n        </div><!-- /.status-display -->\n\n        <d
iv class="cf-section cf-wrapper">\n            <div class="cf-columns two">\n                <div class="cf-column">\n                    <h2>What happened?</h2>\n
                    <p>The origin web server timed out responding to this request.</p>\n                </div>\n              \n                <div class="cf-colu
mn">\n                    <h2>What can I do?</h2>\n                          <h5>If you\'re a visitor of this website:</h5>\n      <p>Please try again in a few min
utes.</p>\n\n      <h5>If you\'re the owner of this website:</h5>\n      <p><span>The connection to the origin web server was made, but the origin web server timed
 out before responding. The likely cause is an overloaded background task, database or application, stressing the resources on your web server. To resolve, please
work with your hosting provider or web development team to free up resources for your database or overloaded application.</span> <a href="https://support.cloudflar
e.com/hc/en-us/articles/200171926-Error-524">Additional troubleshooting information here.</a></p>\n                </div>\n            </div>\n              \n
    </div><!-- /.section -->\n\n        <div class="cf-error-footer cf-wrapper">\n  <p>\n    <span class="cf-footer-item">Cloudflare Ray ID: <strong>446cc5353b272a
67</strong></span>\n    <span class="cf-footer-separator">&bull;</span>\n    <span class="cf-footer-item"><span>Your IP</span>: 52.175.208.26</span>\n    <span cla
ss="cf-footer-separator">&bull;</span>\n    <span class="cf-footer-item"><span>Performance &amp; security by</span> <a href="https://www.cloudflare.com/5xx-error-l
anding?utm_source=error_footer" id="brand_link" target="_blank">Cloudflare</a></span>\n    \n  </p>\n</div><!-- /.error-footer -->\n\n\n    </div><!-- /#cf-error-d
etails -->\n</div><!-- /#cf-wrapper -->\n</body>\n</html>\n'

Hi @clu8 I've added a default timeout of 10s in v0.3.3

You can also change that when you initialise the client along with other requests/aiohttp params.

e.g

client.get_ticker('ETH_SAN', requests_params={'timeout': 5})