Questions tagged [aiohttp]

Use this tag for questions about AIOHTTP – a client/server framework for asyncio Python.

AIOHTTP is an asynchronous asyncio Python web framework for both client and server sides. It supports HTTP, WebSockets, and also MiddleWare and Signals mechanics for the server side.

Useful links:

Related tags:

1628 questions
0
votes
1 answer

Can I use python - aiohttp inside of a GCP cloud function?

I'm trying to route/divvy up some workload to other cloud functions they all take roughly about the same amount of time, but I have to invoke them synchronously. I tried setting this up, and I followed someone's advice when implementing it with…
Gdfelt
  • 161
  • 15
0
votes
1 answer

Asyncio HTTP requests without blocking main thread

I have a main thread which always needs to be available to read keyboard keypress input. On each keypress I have to run 4 functions such as displaying, saving to a file, and making an HTTP request etc. The keypresses can happen quicker than…
0
votes
1 answer

Aiohttp adding values to string in discord.py

I am trying to add the user's response into the URL. My code is async def dungeondata(): async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session: async with…
ENORMOUZ
  • 25
  • 2
  • 11
0
votes
1 answer

coroutine was never awaited, async multithreading

async def existance(s, name): async with s.head(f"https://example.com/{name}") as r1: if r1.status == 404: print('wow i worked') async def process(names): with ThreadPoolExecutor(max_workers=3) as executor: async…
0
votes
0 answers

Python: aiohttp responses delayed when receiving concurrent requests

I am using aiohttp for the first time in my python app for web server. I try to upload an image to the server, do some processing and return the response. Here is the code @routes.post('/') async def handle(request: web.Request) ->…
varunkr
  • 5,364
  • 11
  • 50
  • 99
0
votes
1 answer

Creating a connection pool in aiohttp with aiomysql

I need to be able access an aiomysql connection pool within the aiohttp app like so async def get(request): async with request.app['db'].acquire() as conn: async with connection.cursor() as cur: await cur.execute('SELECT…
user14473331
  • 155
  • 5
0
votes
2 answers

gunicorn error while running python script

Here is my python code. from aiohttp import web if __name__ == "__main__": app = web.Application() cors = aiohttp_cors.setup(app) app.on_shutdown.append(on_shutdown) app.router.add_get("/", index) …
soubhagya
  • 788
  • 2
  • 12
  • 37
0
votes
2 answers

Python aiohttp module: ambiguous .content attribute

Here is a little code snippet: import aiohttp import aiofiles async def fetch(url): # starting a session async with aiohttp.ClientSession() as session: # starting a get request async with session.get(url) as response: …
user13848261
0
votes
1 answer

How to fix aiopg exception on initialization engine in aiohttp application?

I'm studying aiohttp using official documentation and on step where I must get database connection the code raises exception. I have a function and call it with: app.on_startup.append(function) like in the documentation. Function's code is…
0
votes
2 answers

Python API Unable to GET request using aiohttp

I'm trying to make my own api using aiohttp. It works perfectly fine on localhost:8080, Is there a way to connect it into heroku site , I tried to load with https://dumboapi.herokuapp.com/getmeme/ but it doesn't work :/ This is my code: subreddit =…
Cedric
  • 142
  • 10
0
votes
0 answers

how to make this code asynchronous with await in python

I'm trying to write my first asynchronous code with aiohttp, but somehow I don't understand where shall the program await in this example: async def fetch_cookies(): async with aiohttp.ClientSession() as session: async with…
Herminne
  • 81
  • 1
  • 8
0
votes
0 answers

Cannot connect to host www.reddit.com:443 ssl:True

I wanted to use aiohttp.request in order to get Reddit post, but when I ran the code it gives me this error, any possible solution? Code: @command(name='meme') @guild_only() async def meme_cmd(self, ctx): async with request("GET",…
Cedric
  • 142
  • 10
0
votes
1 answer

Blocking database driver & async web framework

Async web frameworks are here though ORMs often aren't async-friendly. Though is there any reason to care about this in the typical scenario where your database is hosted in the same local network as your server for the average service? The waiting…
Rodrigo Oliveira
  • 1,452
  • 4
  • 19
  • 36
0
votes
2 answers

Run slow background blocking task from asyncio loop

I have asyncio crawler, that visits URLs and collects new URLs from HTML responses. I was inspired that great tool: https://github.com/aio-libs/aiohttp/blob/master/examples/legacy/crawl.py Here is a very simplified piece of workflow, how it…
0
votes
0 answers

the part of asyncio that checks if the response is ready

In the asynchronous code below, what is the thing that checks if the response is ready, for each task to resume the execution ? I understand that the 50 requests are all sent one after another at async with session.get(url). But how does it then…
trogne
  • 3,402
  • 3
  • 33
  • 50