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
10
votes
1 answer

How to post Multipart Form Data through python aiohttp ClientSession

I am trying to asynchronously send some Multipart-Encoded Form Data as a post request, mainly a file and two other fields. Before trying to use asyncio I was doing the process synchronously with requests-toolbelt MultipartEncoder…
10
votes
2 answers

Aiohttp server max connections

I cannot understand the reason aiohttp (and asyncio in general) server implementation does not provide a way to limit max concurrent connections limit (number of accepted sockets, or number of running requests handlers).…
Alexandr Tatarinov
  • 3,946
  • 1
  • 15
  • 30
10
votes
1 answer

How to close aiohttp ClientSession

I am trying to make an app that might live for a day, a week or longer. Dyring the app's lifetime, it will make requests to different API's. Some of these apis might require log in, so it is important that i have access to cookies at all times. So…
G0rt
  • 221
  • 1
  • 2
  • 7
10
votes
4 answers

"RuntimeError: This event loop is already running"; debugging aiohttp, asyncio and IDE "spyder3" in python 3.6.5

I'm struggling to understand why I am getting the "RuntimeError: This event loop is already running" runtime error. I have tried to run snippets of code from "https://aiohttp.readthedocs.io/en/stable/" however, I keep getting the same issue. Code…
Ryan Baumgartner
  • 131
  • 1
  • 1
  • 6
10
votes
2 answers

limit number of concurrent requests aiohttp

I'm downloading images using aiohttp, and was wondering if there is a way to limit the number of open requests that haven't finished. This is the code I currently have: async def get_images(url, session): chunk_size = 100 # Print statement…
Jasonca1
  • 4,848
  • 6
  • 25
  • 42
10
votes
1 answer

Asynchronous HTTP calls using aiohttp/asyncio fail with "Cannot connect to host [Network is unreachable]"

I am implementing a fast async REST interface caller with which I want to upload data in an synchronous manner. For now I am about to build the async framework that just calls the python page in an async manner and measures the delay. Here is the…
Ben
  • 2,314
  • 1
  • 19
  • 36
10
votes
3 answers

Python asyncio/aiohttp: ValueError: too many file descriptors in select() on Windows

Note: Future readers be aware, this question was old, formatted and programmed in a rush. The answer given may be useful, but the question and code probably not. Hello everyone, I'm having trouble understanding asyncio and aiohttp and making both…
Josep
  • 676
  • 2
  • 8
  • 14
10
votes
2 answers

Running aiohttp server using gunicorn

I am trying to run a aiohttp based server using Gunicorn. Here is the command: gunicorn aiohttpdemo_polls:app --bind 127.0.0.1:8080 It returns: Failed to find application: 'aiohttpdemo_polls' But when I am running it using python -m like…
Alex Benz
  • 395
  • 4
  • 14
10
votes
1 answer

python 3.5 asyncio and aiohttp Errno 101 Network is unreachable

I am using python 3.5 on Ubuntu 16. I am trying to use aiohttp to write a simple client. Here is the code I have. I took it from here. It's the first code sample, with ssl check disabled: import aiohttp import asyncio import async_timeout async def…
mayk93
  • 1,489
  • 3
  • 17
  • 31
10
votes
2 answers

Using tornado with aiohttp (or other asyncio-based libraries)

I want to use tornado with asyncio libraries like aiohttp and native python 3.5 coroutines, and it seems to be supported in the latest tornado release (4.3). However when using it in tornado event loop, the request handler hangs indefinitely. When…
Leonth
  • 711
  • 1
  • 9
  • 19
10
votes
2 answers

Does aiohttp have ORM?

There is relatively new Python 3 aiohttp library that contains client/server. Does it contain ORM? If not - is it possible to use it with 3-rd party ORM? If not possible - for which purpose it could be used? I don't mean that app could not be…
wolendranh
  • 4,202
  • 1
  • 28
  • 37
10
votes
2 answers

aiohttp - exception ignored message

I'm running the following code which makes 5 requests via aiohttp: import aiohttp import asyncio def fetch_page(url, idx): try: url = 'http://google.com' response = yield from aiohttp.request('GET', url) …
okoboko
  • 4,332
  • 8
  • 40
  • 67
9
votes
3 answers

ERROR: Could not build wheels for aiohttp, which is required to install pyproject.toml-based projects

Python version: 3.11 Installing dependencies for an application by pip install -r requirements.txt gives the following error: socket.c -o build/temp.linux-armv8l-cpython-311/aiohttp/_websocket.o aiohttp/_websocket.c:198:12: fatal error:…
Anton Samokat
  • 542
  • 1
  • 6
  • 15
9
votes
1 answer

Maximize number of parallel requests (aiohttp)

tl;dr: how do I maximize number of http requests I can send in parallel? I am fetching data from multiple urls with aiohttp library. I'm testing its performance and I've observed that somewhere in the process there is a bottleneck, where running…
pieca
  • 2,463
  • 1
  • 16
  • 34
9
votes
1 answer

aiohttp concurrent GET requests lead to ClientConnectorError(8, 'nodename nor servname provided, or not known')

I am stumped by a problem seemingly related to asyncio + aiohttp whereby, when sending a large number of concurrent GET requests, over 85% of the requests raise an aiohttp.client_exceptions.ClientConnectorError exception that ultimately stems…
Brad Solomon
  • 38,521
  • 31
  • 149
  • 235