'Async Client Binance

I'm trying Async Client, and also, I'm not really familiar with async programming, so I'm trying to grasp it.

I'm confused about what the "await client.close_connection()" part does. Is it necessary to have that? Because the code just works fine without that.

Code:

async def main():
    client = await AsyncClient.create(config.API_KEY, config.API_SECRET_KEY, tld='com')
    bm = BinanceSocketManager(client)
    # start any sockets here, i.e a trade socket
    ts = bm.trade_socket('BTCUSDT')
    # then start receiving messages
    async with ts as tscm:
        while True:
            res = await tscm.recv()
            print(res)

    await client.close_connection()

if __name__ == "__main__":

    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source