yahooquery
yahooquery copied to clipboard
Ticker fails when getaddrinfo fails (socket.gaierror [Errno 11002]
Describe the bug Occasional failure (probable when lots of traffic to yahoo.com). Socket hrows exception that is not handled.:
File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\connection.py", line 160, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\util\connection.py", line 61, in create_connection for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): File "C:\Users\chf\Anaconda3\lib\socket.py", line 752, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 677, in urlopen chunked=chunked, File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 381, in _make_request self._validate_conn(conn) File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 978, in _validate_conn conn.connect() File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\connection.py", line 309, in connect conn = self._new_conn() File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\connection.py", line 172, in _new_conn self, "Failed to establish a new connection: %s" % e urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x00000237E47755C8>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\chf\Anaconda3\lib\site-packages\requests\adapters.py", line 449, in send timeout=timeout File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 767, in urlopen **response_kw File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 767, in urlopen **response_kw File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 767, in urlopen **response_kw [Previous line repeated 2 more times] File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 727, in urlopen method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "C:\Users\chf\Anaconda3\lib\site-packages\urllib3\util\retry.py", line 439, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='query2.finance.yahoo.com', port=443): Max retries exceeded with url: /v6/finance/quote?lang=en-US®ion=US&corsDomain=finance.yahoo.com&symbols=%5EDJI%2C%5EGSPC%2C%5EIXIC%2CAAPL%2CAEP%2CAMGN%2CAMZN%2CARCC%2CBAC%2CBLK%2CBTC-USD%2CC%2CCASH%2CCAT%2CCB%2CCI%2CCL%3DF%2CCSCO%2CCVS%2CCVX%2CDEO%2CDHR%2CDIS%2CEILDX%2CEMB%2CEURUSD%3DX%2CFADMX%2CFAGIX%2CFDCAX%2CFIPDX%2CFLPSX%2CFNMIX%2CFSKAX%2CFSPSX%2CFSRNX%2CFSSNX%2CFXNAX%2CGC%3DF%2CGD%2CGOOG%2CHD%2CHON%2CIBM%2CIGSB%2CINTC%2CJ%2CJNJ%2CJPC%2CJPM%2CK%2CKKR%2CLDLFX%2CLMBS%2CMDLZ%2CMDYG%2CMRK%2CMSFT%2CNAD%2CNKE%2CNSRGY%2CNVHIX%2COHI%2CONEQ%2CORCL%2CPFE%2CPFF%2CPG%2CPHYZX%2CPTY%2CQCOM%2CRTX%2CSLB%2CSPY%2CSYK%2CT%2CTEL%2CTMO%2CUPS%2CUSB%2CV%2CVBK%2CVIGIX%2CVLO%2CVYM%2CVZ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000237E47755C8>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\chf\Finance\curVersion\ntrack.py", line 194, in
To Reproduce
Trying to price 85 symbols, Not asynchronous,
tic = Ticker(merged) tval = tic.quotes
Expected behavior Gives me quotes
Desktop (please complete the following information):
- OS: Win 10 Pro, Using Anaconda, python 3.7.9
- Feeds quote info into Xlwings to update Excel spreadsheet
How often are you making this request? I haven't run into this problem yet but my guess is that YF is actively blocking the request either because the number of symbols is so great or because of the frequency of your requests is high.
That’s possible. I’m hitting it about once a minute with 85 symbols. I had been done that via the main finance.yahoo.com interface without any problem (averaged ~4-5 seconds using 8 parallel processes to get results – your ticker runs it 10 times faster).
Thanks for the follow up!
Charlie
From: Doug [email protected] Sent: Wednesday, October 14, 2020 5:46 PM To: dpguthrie/yahooquery [email protected] Cc: chfiii [email protected]; Author [email protected] Subject: Re: [dpguthrie/yahooquery] Ticker fails when getaddrinfo fails (socket.gaierror [Errno 11002] (#45)
How often are you making this request? I haven't run into this problem yet but my guess is that YF is actively blocking the request either because the number of symbols is so great or because of the frequency of your requests is high.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dpguthrie/yahooquery/issues/45#issuecomment-708677508 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACX2GP2JBOSETESJXHWOL3LSKYLYJANCNFSM4SJD25SA .
Most likely a rate limiting issue on the YF side (not much I can do here).