Category "python-asyncio"

await vs asyncio.sleep: Does await keyword return control to the loop? Or maybe Pythons's asyncio StreamReader.read() is blocking?

I encountered a strange situation. StreamReader in asyncio seems to be blocking. received = asyncio.Queue() async def read_loop(): while True: rece

asyncio.wait not returning on first exception

I have an AMQP publisher class with the following methods. on_response is the callback that is called when a consumer sends back a message to the RPC queue I se

FastAPI - dynamic inputs for different data types

I have to create a very generic endpoint for a user. The user may send JSON data or may upload a file to this endpoint. There are multiple options on how to han

Python asyncio event loop add wait for server connection

I want to establish a connection with asyncio.open_connection but I can't get it to work. first I create the loop and a queue _loop = asyncio.new_event_loop() _

Async SqlAlchemy with FastAPI: Getting single session for all requests

I have recently migrated a REST API coded with FastApi to the new SQLAlchemy 1.4+ Async Version. My app compiles correctly and the database seems to setup just

Why is asyncio session is closed error occurring with my Pymyq script?

I have written a script which uses the Python Pymyq library to interact with Chamberlin smart home devices, in this case a garage door. This script ran success

simultaneous (async) work - getting msg receiving and placing order/selling in auto bot w websocket

''' I would like to get async working for purchasing ordering while continuously getting realtime price update by websocket receving. However, when I execute th

How to profile/benchmark Python ASYNCIO code?

How do I profile/benchmark an assynchronous Python script (which uses ASYNCIO)? I you would usualy do totalMem = tracemalloc.get_traced_memory()[0] totalTime

Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] for Python 3.9

I am trying to install Python 3.9 in order to access some updated libraries compared to Python 3.6. However, when I run my code, none of the previous libraries

python websockets set port as None, how can get which port used?

I used python websockets library create a websocket server, to avoid port has been used by other application, I set port as None, let system choose a port for m

How stream a response from a Twisted server?

Issue My problem is that I can't write a server that streams the response that my application sends back. The response are not retrieved chunk by chunk, but fro

ValueError: set_wakeup_fd only works in main thread on Windows on Python 3.8 with Django 3.0.2 or Flask 2.0.0

When I run my Django Web application with Apache2.4.41 + Python 3.8.1 + Django 3.0.2 + MySQL 8.0.19 on Windows 10 Professional version it throws Value Error at

Unable to achieve async/parallel behavior inside for loop while using FastAPI and Ormar

I am using FastAPI and have an async route that needs to do many things like making calls to other API endpoints, and reading/writing to a database. It iterates

Watch stdout and stderr of a subprocess simultaneously

How can I watch standard output and standard error of a long-running subprocess simultaneously, processing each line as soon as it is generated by the subproces

How to get IP address and port of newly accepted connection in Python asyncio server?

I'm using the asyncio library in Python 3.8 https://docs.python.org/3/library/asyncio.html I am creating a server, and in the "newly accepted connection" callb

asyncio not working on Google Cloud Functions

I have this function which works fine locally on my machine with python 3.8, but it throws runtime error on Google Cloud Functions. def telegram_test(request):

Is there a way to take advantage of multiple CPU cores with asyncio?

I've created a simple HTTP Server with python and asyncio. But, I have read that asyncio-based servers can only take advantage of one CPU core. I am trying to f

Getting live output from asyncio subprocess

I'm trying to use Python asyncio subprocesses to start an interactive SSH session and automatically input the password. The actual use case doesn't matter but i

Python discord bot - coroutine was never awaited

I'm working on a Discord bot and it works to some degree but it keeps crashing every couple minutes. It gives me an error like Task was detroyed but it's pendi

FastAPI runs api-calls in serial instead of parallel fashion

I have the following code: import time from fastapi import FastAPI, Request app = FastAPI() @app.get("/ping") async def ping(request: Request):