Closed yhmickey closed 2 months ago
RestClient on error---------- [2024-08-17T09:18:42.106395]: Unhandled RestClient Error:<class 'RuntimeError'> request:request : GET /fapi/v1/time because terminated: headers: None params: None data: None json: None response:
Exception trace: Traceback (most recent call last): File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/vnpy_rest/rest_client.py", line 285, in _process_request response: Response = await self._get_response(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/vnpy_rest/rest_client.py", line 266, in _get_response cr: ClientResponse = await self.session.request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/client.py", line 657, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 564, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 973, in _createconnection , proto = await self._create_proxy_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1472, in _create_proxy_connection return await self._start_tls_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1207, in _start_tls_connection sslcontext = cast(ssl.SSLContext, await self._get_ssl_context(req)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1027, in _get_ssl_context return await self._make_or_get_ssl_context(False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1033, in _make_or_get_ssl_context return await self._made_ssl_context[verified] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: Task <Task pending name='Task-1' coro=<RestClient._process_request() running at /Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/vnpy_rest/rest_client.py:285> cb=[_chain_future.._call_set_state() at /Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/asyncio/futures.py:394]> got Future attached to a different loop
RestClient on error---------- [2024-08-17T09:18:42.108887]: Unhandled RestClient Error:<class 'RuntimeError'> request:request : GET /fapi/v1/exchangeInfo because terminated: headers: None params: None data: None json: None response:
Exception trace: Traceback (most recent call last): File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/vnpy_rest/rest_client.py", line 285, in _process_request response: Response = await self._get_response(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/vnpy_rest/rest_client.py", line 266, in _get_response cr: ClientResponse = await self.session.request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/client.py", line 657, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 564, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 973, in _createconnection , proto = await self._create_proxy_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1472, in _create_proxy_connection return await self._start_tls_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1207, in _start_tls_connection sslcontext = cast(ssl.SSLContext, await self._get_ssl_context(req)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1027, in _get_ssl_context return await self._make_or_get_ssl_context(False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1033, in _make_or_get_ssl_context return await self._made_ssl_context[verified] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: await wasn't used with future
主界面显示Data Websocket API is connected. 但是报以上错误, 无法正常连接.
mac m1 系统.
我们已经重新开发实现了vnpy_evo.websocket和vnpy_evo.rest两个模块。
使用线程池 + 同步客户端的方式,替代了官方基于asyncio的实现。
经过我们测试基本解决了各种奇怪的异步问题,同时也方便各种脚本使用。
这里也分享我们团队的经验:
RestClient on error---------- [2024-08-17T09:18:42.106395]: Unhandled RestClient Error:<class 'RuntimeError'> request:request : GET /fapi/v1/time because terminated: headers: None params: None data: None json: None response:
Exception trace: Traceback (most recent call last): File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/vnpy_rest/rest_client.py", line 285, in _process_request response: Response = await self._get_response(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/vnpy_rest/rest_client.py", line 266, in _get_response cr: ClientResponse = await self.session.request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/client.py", line 657, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 564, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 973, in _createconnection , proto = await self._create_proxy_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1472, in _create_proxy_connection return await self._start_tls_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1207, in _start_tls_connection sslcontext = cast(ssl.SSLContext, await self._get_ssl_context(req)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1027, in _get_ssl_context return await self._make_or_get_ssl_context(False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1033, in _make_or_get_ssl_context return await self._made_ssl_context[verified] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: Task <Task pending name='Task-1' coro=<RestClient._process_request() running at /Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/vnpy_rest/rest_client.py:285> cb=[_chain_future.._call_set_state() at /Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/asyncio/futures.py:394]> got Future attached to a different loop
RestClient on error---------- [2024-08-17T09:18:42.108887]: Unhandled RestClient Error:<class 'RuntimeError'> request:request : GET /fapi/v1/exchangeInfo because terminated: headers: None params: None data: None json: None response:
Exception trace: Traceback (most recent call last): File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/vnpy_rest/rest_client.py", line 285, in _process_request response: Response = await self._get_response(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/vnpy_rest/rest_client.py", line 266, in _get_response cr: ClientResponse = await self.session.request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/client.py", line 657, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 564, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 973, in _createconnection , proto = await self._create_proxy_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1472, in _create_proxy_connection return await self._start_tls_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1207, in _start_tls_connection sslcontext = cast(ssl.SSLContext, await self._get_ssl_context(req)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1027, in _get_ssl_context return await self._make_or_get_ssl_context(False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jerry/miniconda3/envs/vnpy_evo/lib/python3.12/site-packages/aiohttp/connector.py", line 1033, in _make_or_get_ssl_context return await self._made_ssl_context[verified] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: await wasn't used with future