Closed sapph1re closed 4 years ago
Yep same here. There's no AsyncClient and also the DepthCacheManager and BinanceSocketManager are elsewhere.
from binance.depthcache import DepthCacheManager
from binance.websockets import BinanceSocketManager
...perhaps?
Apparently, it's an error of aiohttp, which is used here. Its ClientSession is recommended to be run in a context manager: https://stackoverflow.com/questions/46112848/python-package-aiohttp-has-a-warning-message-unclosed-client-session
Another way is closing the aiohttp.ClientSession explicitly: await self.session.close()
but I'm not sure where exactly it would be good to do it. Make a special class method for that, like stop()
? What would be the best approach?
@sapph1re did you find a fix / workaround for this?
@sapph1re did you find a fix / workaround for this?
sorry, my previous (deleted) answer was misleading.
I made a stop()
method in the exchange wrapper class, which explicitly calls await self._client.session.close()
where self._client
is the AsyncClient instance.
I'm still getting this error. I guess it has not been fixed.
I still get the error
You need close conection
async def main():
client = await AsyncClient.create()
print(await client.get_server_time())
# all code here
await client.close_connection() # <--- you need this line. insert it in the end of main function
Describe the bug I simply instantiate AsyncClient like demonstrated in readme, and its usage is always followed with an "Unclosed client session" error.
To Reproduce
Output:
Expected behavior Expected not to have errors. Should I somehow gracefully close/destroy AsyncClient?
Environment (please complete the following information):