Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can it try again after throw "Connection timed out " Exception #5

Open
ranglang opened this issue Oct 21, 2020 · 3 comments
Open

can it try again after throw "Connection timed out " Exception #5

ranglang opened this issue Oct 21, 2020 · 3 comments

Comments

@ranglang
Copy link

Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 301, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 168, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7ff035ea6c88>: Failed to establish a new connection: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='dataapi.joinquant.com', port=443): Max retries exceeded with url: /apis (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff035ea6c88>: Failed to establish a new connection: [Errno 110] Connection timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "examples/recorders/joinquant_data_runner2.py", line 22, in record_margin_trading
MarginTrading.record_data(provider='joinquant', sleeping_time=1)
File "/usr/local/lib/python3.7/site-packages/zvt-0.9.1-py3.7.egg/zvt/contract/schema.py", line 153, in record_data
r.run()
File "/usr/local/lib/python3.7/site-packages/zvt-0.9.1-py3.7.egg/zvt/contract/recorder.py", line 484, in run
raise raising_exception
File "/usr/local/lib/python3.7/site-packages/zvt-0.9.1-py3.7.egg/zvt/contract/recorder.py", line 403, in run
timestamps=timestamps)
File "/usr/local/lib/python3.7/site-packages/zvt-0.9.1-py3.7.egg/zvt/recorders/joinquant/fundamental/joinquant_margin_trading_recorder.py", line 31, in record
df = get_mtss(code=to_jq_entity_id(entity), date=to_time_str(start))
File "/usr/local/lib/python3.7/site-packages/jqdatapy/api.py", line 98, in get_mtss
return request_jqdata(method='get_mtss', code=code, date=date, end_date=end_date, parse_dates=['date'])
File "/usr/local/lib/python3.7/site-packages/jqdatapy/api.py", line 167, in request_jqdata
token = get_token(force=True)
File "/usr/local/lib/python3.7/site-packages/jqdatapy/api.py", line 154, in get_token
jqdata_env["token"] = _get_token(jqdata_env["username"], jqdata_env["password"])
File "/usr/local/lib/python3.7/site-packages/jqdatapy/api.py", line 187, in _get_token
response = requests.post(url, data=json.dumps(body))
File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='dataapi.joinquant.com', port=443): Max retries exceeded with url: /apis (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff035ea6c88>: Failed to establish a new connection: [Errno 110] Connection timed out'))

@ranglang
Copy link
Author

it seem the sleep duration should be longer

@ranglang
Copy link
Author

    timestamps=timestamps)
  File "/usr/local/lib/python3.7/site-packages/zvt-0.9.1-py3.7.egg/zvt/recorders/joinquant/fundamental/stock_valuation_recorder.py", line 38, in record
    count=min(count.days, 500))
  File "/usr/local/lib/python3.7/site-packages/jqdatapy/api.py", line 87, in get_fundamentals
    parse_dates=parse_dates)
  File "/usr/local/lib/python3.7/site-packages/jqdatapy/api.py", line 168, in request_jqdata
    resp = _request_jqdata(method=method, token=token, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/jqdatapy/api.py", line 206, in _request_jqdata
    raise HttpAccessError(code=response.status_code, msg=response.text)
jqdatapy.api.HttpAccessError

还是得增加retry

@ranglang ranglang reopened this Oct 22, 2020
@foolcage
Copy link
Member

收到,接下来会加入 异常处理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants