Skip to content

Tag: python-asyncio

How to nullify python asyncio global variables?

I am writing a personal Telegram Bot to collect statistics on my accounts The main task of the bot is to send async requests to the API and display information via Telegram. Everything works as it should, but the problem is with global variables, or rather, their incorrect counting. An example of one of my functions: Function result: Bot

Asyncio Streams automatically restarts to read data even after writer.close() is run

I followed the tutorial in to read data from a sensor (TCP protocol, PC as the server): The program is supposed to finish after 1 second data transmission. However, the output is: It repeated automatically and infinitely. What is the reason for this and How could I solve it? Answer Problem serve_forever() listens to the port indefinitely. So, even

websocket await close vs await wait_closed

I’m using the websockets package on python and I’m opening a connection as a client, but NOT in a block context like this: I’m opening the connection like this: The thing is that I don’t under stand what is the right way to close the connection. The document explains here about await close() and await wait_closed(), but I don’t understand