Category "python-asyncio"

ThreadPoolExecutor communication with separate asyncio loop

I have a task that is IO bound running in a loop. This task does a lot of work and is often times hogging the loop (Is that the right word for it?). My plan is

How to make request without blocking (using asyncio)?

I would like to achieve the following using asyncio: # Each iteration of this loop MUST last only 1 second while True: # Make an async request sleep(1

asyncio and paramiko for concurrent ssh connectivity

I'm trying to speed up the Paramiko SSH connection to a couple of network devices. I want to use asyncio for that purpose, but I'm not sure if my implementation

uploading multiple files UploadFiles FastAPI

Example Here's my code: from typing import List from fastapi import FastAPI, File, UploadFile import asyncio import concurrent.futures app = FastAPI() @app.po

Python asyncio sleep not wakes up

I am trying yo have a progress indicator where one task is doing something while the other indicates a progress. My hello world version of this things goes to s

Django ORM and Async

So, I'm trying to create a polling system internal to django commands for fun and to learn async/django. I'm using django_tenants, although it's not overly impo

SqlAlchemy asyncio orm: How to query the database

In SqlAlchemy async orm engine how do I query a table and get a value or all? I know from the non async methods that I can just do SESSION.query(TableClass).get

Asynchronous exception handling in Python

I've the following code using asyncio and aiohttp to make asynchronous HTTP requests. import sys import asyncio import aiohttp @asyncio.coroutine def get(url):

Mac web requests hanging after thousands of requests

I'm facing a very strange issue and am looking for advice on how to debug it more than I am on a simple fix, since I've been unable to create a simple reproduci

How to read lines from file asynchronously and work with them in gather?

I'm trying to replace list of generated numbers with asynchronously reading them from file. How can I do it right? from asyncio import get_event_loop, gather, s

fastapi + aiomysql connection pool stuck after 10 calls

Why aiomysql connection pool stuck after N calls? (N is the maxsize number of connection. Tried the default N=10 and N=3) I thought the acquired connections are

Does the lock in asyncio.Condition have other purpose besides compatibility with threading.Condition?

I'd like to ask about asyncio.Condition. I'm not familiar with the concept, but I know and understand locks, semaphores, and queues since my student years. I c

Rest API asyncio gets stuck while running

Can anyone help me with Rest API asynchronous? I used Asyncio for 4 requests to FTX server. If I run the code, it prints 'balance','position','chart1','chart2'

Using next() on an async generator

A generator can be iterated step by step by using the next() built-in function. For example: def sync_gen(n): """Simple generator""" for i in range(n):

Using next() on an async generator

A generator can be iterated step by step by using the next() built-in function. For example: def sync_gen(n): """Simple generator""" for i in range(n):

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

Difference between websocket and websockets

I don't understand the difference between websocket (websocket client) and websockets. I would like to understand the difference to know which one uses to be op

How to get IP address from aiohttp response

I am have been trying to look into responses from aiohttp requests and have not found a way to get the ipaddress of the specified host: async with aiohttp.Clie

Strange errors with asynchronous requests

async def rss_downloader(rss): global counter async with download_limit: headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Wi

How to use multiprocessing.Event in an asyncio event loop?

I am using the multiprocessing module to create a Process. In this child process, it will run an asyncio event loop, and in the parent process, I am not. How ca