All Questions
984 questions
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
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
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 "...
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 ...
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
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 ...
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....
1
vote
3
answers
86
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 ...
1
vote
3
answers
101
views
Why the async-code is printing these things and in this order?
I'm trying to understand asynchronous programming in Python, and I've stumbled to see the output of the code
import asyncio
async def my_coroutine():
print("Coroutine started")
...
0
votes
2
answers
289
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. ...
1
vote
1
answer
51
views
How to run dependence tasks concurrently with non-dependence ones, and tasks inside for loop?
I am learning asyncio and there is a problem of running a dependence task concurrently with non-dependence ones. So far I couldn't make it work. This is my code:
import asyncio
import random
def ...
0
votes
1
answer
44
views
Any difference between await asyncio.Task and asyncio.Task.result()?
After the task already completed, is there any difference between await asyncio.Task and asyncio.Task.result()?
The only difference in the following code is how I read the value in task.
import ...
0
votes
0
answers
54
views
Is this correct to run a CPU-bound operation using ProcessPoolExecutor in asyncio loop?
I'm trying to run CPU-bound operations in non-blocking style using ProcessPoolExecutor from concurrent.futures module and asyncio.get_running_loop() functions.
I have my function that runs CPU-bound ...
-2
votes
1
answer
312
views
Python-binance and asyncio
I'm trying to get some data from Binance (using python-binance package). My very simple code:
import asyncio
from binance.client import AsyncClient
async def get_data(client):
res = await client....