client_session: <aiohttp.client.ClientSession object at 0x000001B7CD7F9B70>
See original GitHub issueI can get the ticker when I use the first code, but when I use async , the code run wrong, how to slove it ! can you help me? I am use python 3.6 on windows 10 .
the first code:
import ccxt
exchange = ccxt.binance()
symbol = 'BTC/USDT'
ticker = exchange.fetch_ticker(symbol)
print(ticker)
the sencond code:
import asyncio
import ccxt.async as ccxt
async def getticker():
binance = ccxt.binance()
print(await binance.fetch_ticker('BTC/USDT'))
asyncio.get_event_loop().run_until_complete(getticker())
Traceback (most recent call last):
File "C:\Users\SXY004\Anaconda3\lib\site-packages\ccxt\async\base\exchange.py", line 124, in fetch
proxy=self.aiohttp_proxy) as response:
File "C:\Users\SXY004\Anaconda3\lib\site-packages\aiohttp\client.py", line 690, in __aenter__
self._resp = yield from self._coro
File "C:\Users\SXY004\Anaconda3\lib\site-packages\aiohttp\client.py", line 341, in _request
break
File "C:\Users\SXY004\Anaconda3\lib\site-packages\aiohttp\helpers.py", line 727, in __exit__
raise asyncio.TimeoutError from None
concurrent.futures._base.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:/python3/test/test.py", line 10, in <module>
asyncio.get_event_loop().run_until_complete(getticker())
File "C:\Users\SXY004\Anaconda3\lib\asyncio\base_events.py", line 466, in run_until_complete
return future.result()
File "E:/python3/test/test.py", line 8, in getticker
print(await binance.fetch_ticker('BTC/USDT'))
File "C:\Users\SXY004\Anaconda3\lib\site-packages\ccxt\async\binance.py", line 492, in fetch_ticker
await self.load_markets()
File "C:\Users\SXY004\Anaconda3\lib\site-packages\ccxt\async\base\exchange.py", line 153, in load_markets
markets = await self.fetch_markets()
File "C:\Users\SXY004\Anaconda3\lib\site-packages\ccxt\async\binance.py", line 345, in fetch_markets
response = await self.publicGetExchangeInfo()
File "C:\Users\SXY004\Anaconda3\lib\site-packages\ccxt\async\base\exchange.py", line 102, in fetch2
return await self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "C:\Users\SXY004\Anaconda3\lib\site-packages\ccxt\async\base\exchange.py", line 139, in fetch
self.raise_error(RequestTimeout, method, url, e, None)
File "C:\Users\SXY004\Anaconda3\lib\site-packages\ccxt\base\exchange.py", line 274, in raise_error
raise exception_type(output)
ccxt.base.errors.RequestTimeout: binance GET https://api.binance.com/api/v1/exchangeInfo
binance requires to release all resources with an explicit call to the .close() coroutine.
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001AE4AB39B00>
Issue Analytics
- State:
- Created 6 years ago
- Comments:30 (15 by maintainers)
Top Results From Across the Web
Client Reference — aiohttp 3.8.3 documentation
Client session is the recommended interface for making HTTP requests. ... BasicAuth) – an object that represents HTTP Basic Authorization (optional).
Read more >aiohttp: Unclosed client session client_session - Stack Overflow
It's not an error, just a warning. And you can deal with it by closing the session. Try this: async def a(): payload...
Read more >aiohttp-client-manager 1.1.2 - PyPI
Project description. A module to automatically manage aiohttp.ClientSession objects for you to improve performance. The package manages a global cache of ...
Read more >aiohttp Client
Client class¶. Client is a class with embedded aiohttp.ClientSession . Also, we need the REST server URL to connect ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@zhoujinhai, @cmosse see the answer here:
https://github.com/ccxt/ccxt/issues/2324#issuecomment-374968303
Hope it helps.
have you tried:
or just setting the event loop at the top and always using that loop?