Skip to content
Advertisement

Tag: async-await

If I use a helping function for a discord.py command, should I use await to call my helping function or just transfer control to my async helper

I have a command that works to send multiple type of messages that follow the same structure but I am using a helping function to send the message. For simplicity, my code looks similar to this: Option 1: Option 2 is making every function async and calling helper with await. It is my first time creating a discord bot and

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

async_generator’ object is not iterable

I need to return a value in async function. I tried to use synchronous form of return: output: 0 [Finished in 204ms] But it just return value of the first loop, which is not expexted. So changed the code as below: output: TypeError: ‘async_generator’ object is not iterable by using async generator I am facing with this error. How can

Tornado gives error Cannot write() after finish()

I am using the Tornado chat demo example from here: https://github.com/tornadoweb/tornado/tree/master/demos/chat and just altering it very slightly. The code change is just a small class called Connections and a bit in the MessageNewHandler(). All I am doing is just saving a reference to self and trying to write(message) to a previous client. But when I go to save on this

Use the same websocket connection in multiple asynchronous loops (Python)

I am running two loops asynchronously, and want both to have access to the same websocket connection. One function periodic_fetch() fetches some data periodically (every 60 seconds) and sends a message to the websocket if a condition is met. The other retrieve_websocket() receives messages from the websocket and perform some action if a condition is met. As of now, I

Python – getting lost around async

As the title said – I’m having a problem with async stuff. What I’m trying to achieve is written under every function. Sadly in this state of code I’m getting and error: TypeError: object StreamReader can’t be used in ‘await’ expression and at the end RuntimeError: Event loop is closed I was googling for a while and didn’t really find

Advertisement