All Questions
Tagged with asynchronous python-asyncio
1,145 questions
0
votes
1
answer
23
views
Asyncio: read new data from process stdout without blocking monitoring task
I write asynchronous process manager, and up till now I came up with this:
import asyncio
class AsyncLocalProcessManager:
def __init__(self):
self.process = None
async def submit(...
1
vote
1
answer
84
views
Python asyncio - How do awaitables interact with system-level I/O events (e.g., serial ports)?
I’m learning asynchronous programming in Python using asyncio and want to understand how low-level awaitables work, particularly for system events like serial port communication. For example, ...
1
vote
1
answer
45
views
Asynchronously running a function in the background while sending results in Python
I have a Python script which I would like to a) Continuously listen for requests from an API, and b) Run an expensive algorithm continuously in the background. The results from the algorithm are saved ...
0
votes
2
answers
99
views
Gracefully terminate `asyncio` program in Python with a full queue
The Problem
I have a simplified example of an asynchronous program (Python 3.9) that is not working when exceptions are raised in futures, and I am looking for ways to gracefully terminate it.
In ...
0
votes
3
answers
83
views
Why CPU bound task doesn't block asyncio event loop?
I want to go deep in asynchronous task execution in python and I made experiment when CPU Bound task runs with IO bound task simultaneously.
I suppose that CPU Bound task blocks the event loop and IO ...
1
vote
1
answer
78
views
How to "swallow" python's asyncio library's TimeoutError exception
I have a python script that connects to a server and downloads a large amount of videos and photos. And when I say large, I mean in the tens of thousands. The total amount of data to be downloaded ...
0
votes
0
answers
49
views
Asyncio async funcitons hangs with asyncio.gather. (the code works without asyncio.gather)
The following code runs well if did not put the async functions inside a asyncio.gather and let them run one after another (with awaits). But when I add them to an asyncio.gather, it prints "...
102
votes
2
answers
84k
views
FastAPI runs API calls in serial instead of parallel fashion
I have the following code:
from fastapi import FastAPI, Request
import time
app = FastAPI()
@app.get("/ping")
async def ping(request: Request):
print("Hello")
time....
291
votes
10
answers
393k
views
Simplest async/await example possible in Python
I've read many examples, blog posts, questions/answers about asyncio / async / await in Python 3.5+, many were complex, the simplest I found was probably this one.
Still it uses ensure_future, and for ...
0
votes
1
answer
70
views
ProcessPoolExecutor() with asyncio hangs randomly
I have an async service that processes data. My current approach is to process different folds created using TimeSeriesSplit in parallel, since this is a CPU heavy task I decided to uses concurrent....
0
votes
0
answers
37
views
SFTP File transfer performance using Paramiko vs Asyncssh
I am comparing 2 different methods to download files from a sftp server.
Using Paramiko.Transport(), adjusting the buffer size and downloading the file in chunks
Using Asyncssh, also adjusting the ...
0
votes
2
answers
520
views
I can't understand what's wrong with my loop/asyncio when trying to run a telethon script
I can't understand what's wrong with my loop/asyncio when trying to run a telethon script
I've tried multiple approaches, but I constatly get errors when trying to run the client with asyncio - so ...
1
vote
3
answers
85
views
How to run async code in IPython startup files?
I have set IPYTHONDIR=.ipython, and created a startup file at .ipython/profile_default/startup/01_hello.py. Now, when I run ipython, it executes the contents of that file as if they had been entered ...
153
votes
11
answers
111k
views
How to limit concurrency with Python asyncio?
Let's assume we have a bunch of links to download and each of the link may take a different amount of time to download. And I'm allowed to download using utmost 3 connections only. Now, I want to ...
0
votes
2
answers
286
views
Is it safe to create asyncio event loop in one thread and run it in another thread while having ability to cancel it from outside the thread (python3)
I want to know if it's safe to create an asyncio event loop in one thread and run the loop in another while having the ability to cancel it from outside the thread in which the event loop is running. ...