I made some pretty simple script which pulls data from clicky.com api but for some reason it does not work as expected from time to time. Sometimes it gets results but another time I am getting the following errors which I cant debug. I am fairly new to asyncio and aiohttp How to debug this? Whats the problem here? edited:
Tag: python-asyncio
missing some messages in websocket client?
I am trying to implement a websocket client that connects to the popular crypto exchange FTX. I have simplified my problem to the following example code below: The output of the program overall is as expected, but with one major problem: the cumulative trading volume that gets output to the console is WAY too low. It should be about 1,000x-10,000x
Python asyncio loop.run_forever()
I try to do a trading bot and the most things work fine. But everytime the internet connection is gone for a short time, the code fails. I use asyncio run_forever() function and I think that the code should run forever until it gets stopped, but it does not work. Here is my code: And I call the loop like
Asyncio : how to kill a thread in ThreadPoolExecutor by an other coroutine
I have a code like that : The output is as follow : As you can see, I have multiples coroutines that I gather on. The task2 coroutine is particular, because it executes long blocking calls (which are not async) in a separate thread. The problem is that, when the task1 try to cancel task2, it doesn’t work. Question :
Python – Run multiple async functions simultaneously
I’m essentially making a pinger, that makes has a 2d list, of key / webhook pairs, and after pinging a key, send the response to a webhook the 2d list goes as follows: My program is essentially a loop, and I’m not too sure how I can rotate the some_list data, in the function. Here’s a little demo of what
python asyncio.create_task tasks exiting earlier than expected?
I have the following code: It outputs: Notice that world isn’t printed anywhere. Why is the output we see being produced? I was expecting: Because I thought that the asyncio.sleep(i) calls would yield execution to the event loop, at which point the event loop would reschedule them after their respective wait times. Clearly I am misunderstanding. Can someone explain? Answer
Retry async aiohttp requests for certain status codes
What is the best way to retry async API calls using aiohttp? I want to retry the request for the standard socket error, timeout error, etc as well as for certain status codes 500, 501. I have tried using aiohttp_async, but can’t get it to work: Output: Answer It looks like you have installed aiohttp_retry version 2.x but you use
Are there any deliberately unfair (LIFO) synchronisation constructs within Python async?
I’m looking for a way to rate limit a recursive algorithm. To demonstrate the problem I’ll use the example of exploring a directory tree: The problem with this code is the way the number of active tasks explode exponentially. Many of these tasks hold OS resources, so even though tasks themselves are theoretically cheap, running millions simultaneously is going to
Asyncio combined with custom modules and aiohttp
I am trying to sleep a module for a couple seconds, while sleeping, the script should continue running. When the sleep is over, the module should put data[“found”] = True, but the code never reaches past asyncio.sleep() The code should print: “bulbasaur” “do stuff” x 5 “bulbasaur” But bulbasaur never comes back. main.py: pokemon.py: nba.py Answer The issue lies in
How to detect closed websocket in asyncio.gather(*tasks)
I have a list of asyncio tasks which contains with connecting,handshaking and receiving data from a websocket. This process is running correctly but sometimes the connection of one of the websocket (or maybe all of them) is closed. How can I detect and make a new conncetion to the closed one? Here is the code which I use: According to