Skip to main content

All 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(...
IzaeDA's user avatar
  • 397
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, ...
Eledwin's user avatar
  • 75
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 ...
Adam's user avatar
  • 389
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 ...
J.K.'s user avatar
  • 1,615
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 ...
Philipp's user avatar
  • 29
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 ...
mtrojak2's user avatar
  • 123
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 "...
Tharusha Jayasooriya's user avatar
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....
Learning from masters's user avatar
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 ...
Basj's user avatar
  • 46.6k
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....
Ahmed Troudi's user avatar
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 ...
user29818860's user avatar
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 ...
user28854634's user avatar
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 ...
odigity's user avatar
  • 8,306
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 ...
Shridharshan's user avatar
  • 1,587
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. ...
Jishnu's user avatar
  • 130

15 30 50 per page
1
2 3 4 5
77