python-asyncio Questions
2
I am attempting to call an external API (one that is provided by Google) using an async client library (the library is also provided by Google).
The async method that I am attempting to call is asy...
Diplegia asked 20/7, 2022 at 16:25
3
Solved
So I need to call an async function for all items in a list. This could be a list of URLs and an async function using aiohttp that gets a response back from every URL. Now obviously I cannot do the...
Incertitude asked 1/1, 2018 at 18:32
3
Solved
The following is the code I'm trying to get working:
>>> import asyncio
>>> async def foo(loop, iv):
... await asyncio.sleep(1, loop=loop)
... print(f'done: {iv}')
...
>>&...
Deltoid asked 13/1, 2018 at 0:7
1
Solved
python asyncio run_forever or while True is similar but it is a "should I do this..." question.
I am more trying to understand if the internals of python asyncio is basically a
while True...
Vouge asked 11/5 at 15:39
3
Solved
I am trying to send 100 requests at a time to a server http://httpbin.org/uuid using the following code snippet
from fastapi import FastAPI
from time import sleep
from time import time
import requ...
Penthea asked 13/9, 2020 at 16:18
2
We're building an ASGI app using fastapi, uvicorn, sqlalchemy and PostgreSQL. The question is: how should we set pool_size in create_async_engine to not make it a bottleneck comparing to a WSGI app...
Jaws asked 8/6, 2022 at 9:21
1
I have an API build with FastAPI which endpoint submits a task to a celery worker, waits for worker to finish its job and return a result to the user.
Question is what is the correct way to wait th...
Inscription asked 14/2, 2021 at 13:56
4
Solved
I am trying to get the number of rows matched in a one to many relationship. When I try parent.children_count I get :
sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called;
can't call...
Cotidal asked 30/10, 2022 at 11:46
6
Background: I am hosting a flask server alongside a discord client
The flask server just needs to pass on messages from the client to discord and from messages from discord to the client.
I am ge...
Brandybrandyn asked 8/9, 2018 at 5:3
11
Solved
here is my code:
import asyncio
from aiohttp import ClientSession
async def main():
url = "https://stackoverflow.com/"
async with ClientSession() as session:
async with session.get(...
Hyla asked 10/8, 2020 at 20:47
2
My request is to get debugging data from the debugger and pycharm prompt:
Lets say I have an-old-style python synchronous program with a bug:
def listdir(self, remote_path):
with ssh.connect(se...
Lobel asked 13/5, 2020 at 10:10
2
I want to open files from asynchronous processes and I've noticed two different modules that could be used: aiofiles and aiofile. However, I don't seem to find information about pros and cons betwe...
Openfaced asked 20/5, 2022 at 7:59
5
Solved
I am testing an async function that might get deadlocked. I tried to add a fixture to limit the function to only run for 5 seconds before raising a failure, but it hasn't worked so far.
Setup:
pi...
Cholla asked 15/4, 2019 at 7:56
10
I think I'm getting this error because my code calls asyncio.get_event_loop().run_until_complete(foo()) twice. Once from foo() and second time from function called by foo(). My question is then: wh...
Filterable asked 19/10, 2017 at 9:41
3
Solved
Here's a minimal reproducible example of my FastAPI app. I have a strange behavior and I'm not sure I understand the reason.
I'm using ApacheBench (ab) to send multiple requests as follows:
ab -n 1...
Wyattwyche asked 4/2 at 9:46
4
Solved
I am using aiohttp to make asynchronous requests and I want to test my code. I want to mock out requests sent by aiohttp.ClientSession. I am looking for something similar to the way responses handl...
Steppe asked 28/8, 2019 at 19:51
1
I am trying to understand potential slowdown in my FastAPI app.
My understanding is that each time I do an await, a task is scheduled for later, creating a backlog of task to be executed. If the pr...
Trinl asked 13/3 at 15:9
10
Solved
When using asyncio, how do you allow all running tasks to finish before shutting down the event loop
I have the following code:
@asyncio.coroutine
def do_something_periodically():
while True:
asyncio.async(my_expensive_operation())
yield from asyncio.sleep(my_interval)
if shutdown_flag_is_set...
Sorghum asked 6/1, 2015 at 10:6
3
Solved
I am trying to create a Discord bot with Python, however whenever I run the sample code here:
import discord
client = discord.Client()
@client.event
async def on_message(message):
# we do not w...
Athlete asked 24/8, 2019 at 16:35
4
Solved
If I have a coroutine which runs a task which should not be cancelled, I will wrap that task in asyncio.shield().
It seems the behavior of cancel and shield is not what I would expect. If I have a...
Holley asked 25/9, 2018 at 19:55
6
Solved
I'm trying to create a WebSocket command line client that waits for messages from a WebSocket server but waits for user input at the same time.
Regularly polling multiple online sources every seco...
Masorete asked 18/10, 2019 at 15:44
11
I am using aiohttp to make a simple HTTP request in python 3.4 like this:
response = yield from aiohttp.get(url)
The application requests the same URL over and over again so naturally I wanted t...
Shama asked 6/12, 2015 at 11:32
3
I have a web application written with python and the async framework Starlette (https://www.starlette.io/), I need to connect to MongoDB, so I installed the async pymongo driver: motor (https://mot...
Threemaster asked 21/2, 2020 at 21:50
1
The AnyIO library is designed to give a unified interface between asyncio and Trio. It has a TaskGroup class mimicking the Trio Nursery class. Indeed, if using Trio as the backend, it is just an al...
Theiss asked 26/2 at 11:16
5
Solved
Is is possible to start a function like this
async def foo():
while True:
print("Hello!")
without importing the asyncio package (and getting the event loop)?
I am looking for a principle simi...
Stunk asked 23/2, 2016 at 19:0
© 2022 - 2024 — McMap. All rights reserved.