sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
6.06k stars 2.21k forks source link

Unclosed client session #1106

Open gorkem2020 opened 2 years ago

gorkem2020 commented 2 years ago

I'm trying to run a sample code given by the author..

import asyncio
from binance import AsyncClient

async def main():
    client = await AsyncClient.create()
    exchange_info = await client.get_exchange_info()
    tickers = await client.get_all_tickers()

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

throws error;

Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x00000172D0C8DA00> Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x00000172D0F8E160>, 145114.359)]'] connector: <aiohttp.connector.TCPConnector object at 0x00000172D0E88D00>

halfelf commented 2 years ago

just call the async method close_connection().

Grimmjawe commented 2 years ago

await client.close_connection()