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
16
votes
2 answers

Python async/await downloading a list of urls

I'm trying to download over 30,000 files from a FTP server, and after some googling using asynchronous IO seemed a good idea. However, the code below failed to download any files and returns a Timeout Error. I'd really appreciate any help!…
Yi Zhou
  • 305
  • 1
  • 3
  • 7
15
votes
2 answers

aiohttp: Unclosed client session client_session

I have a test.py file and a AsyncioCurl.pyfile. I already use session instead of just aiohttp.request But it also give me this error: Unclosed client session client_session: Unclosed…
user10733862
15
votes
4 answers

aiohttp: when is the response.status available?

The Getting Started docs for aiohttp give the following client example: async with aiohttp.ClientSession() as session: async with session.get('https://api.github.com/events') as resp: print(resp.status) print(await…
robin.keunen
  • 153
  • 1
  • 1
  • 6
14
votes
2 answers

TypeError: An asyncio.Future, a coroutine or an awaitable is required

I'm trying to make an asynchronous web scraper using beautifulsoup and aiohttp.This is my initial code to start things.I'm getting a [TypeError: An asyncio.Future, a coroutine or an awaitable is required] and having a hard time figuring out what is…
user7657046
  • 334
  • 1
  • 2
  • 11
14
votes
1 answer

Aiohttp ClientSession outside coroutine

I have a REST API wrapper which is supposed to run in an interactive Python session. HTTP requests are made both through an automated background thread (which uses the API wrapper) and manually by the end user through the interactive session. I am…
Gustavo Bezerra
  • 9,984
  • 4
  • 40
  • 48
14
votes
3 answers

Is there any way to use aiohttp client with socks proxy?

Looks like aiohttp.ProxyConnector doesn't support socks proxy. Is there any workaround for this? I would be grateful for any advice.
Mikhail Gerasimov
  • 36,989
  • 16
  • 116
  • 159
14
votes
4 answers

asynchronous aiohttp requests fails, but synchronous requests succeed

With the following code I get Cannot connect to host ...:443 ssl:True when I use the asynchronous aiohttp. When I use synchronous requests, it succeeds. The whitehouse.gov links fail, but the google.com succeeds for both async and sync cases. What…
Tim
  • 1,013
  • 3
  • 17
  • 36
13
votes
2 answers

How do I make parallel async HTTP requests using httpx (versus aiohttp) in Python?

This was based on a typo, and simple mistake. Not deleting since it has sample code for httpx. I'm attempting to leverage asyncio to parallelize several long-ish running web requests. Because I'm migrating from the requests library, I would like to…
Steven Borg
  • 641
  • 1
  • 6
  • 14
13
votes
1 answer

Understanding aiohttp.TCPConnector pooling & connection limits

I am experimenting with the limit and limit_per_host parameters to aiohttp.connector.TCPConnector. In the script below, I pass connector = aiohttp.connector.TCPConnector(limit=25, limit_per_host=5) to aiohttp.ClientSession, then open 2 requests to…
Brad Solomon
  • 38,521
  • 31
  • 149
  • 235
13
votes
2 answers

ssl/asyncio: traceback even when error is handled

Trying to download and process jpegs from URLs. My issue isn't that certificate verification fails for some URLs, as these URLs are old and may no longer be trustworthy, but that when I try...except... the SSLCertVerificationError, I still get the…
deasmhumnha
  • 456
  • 4
  • 12
13
votes
1 answer

How to manage a single aiohttp.ClientSession?

As a learning exercise, I'm trying to modify the quickstart example of aiohttp to fetch multiple urls with a single ClientSession (the docs suggest that usually one ClientSession should be created per application). import aiohttp import…
Tamás Szelei
  • 23,169
  • 18
  • 105
  • 180
13
votes
2 answers

How to set up logging for aiohttp.client when making request with aiohttp.ClientSession()?

I have some code making sequence of requests to some API. I'd like to set up common logging for all, how can I set this up? Let's say my code looks like this import aiohttp import asyncio async def fetch(client): async with…
Pawel Miech
  • 7,742
  • 4
  • 36
  • 57
12
votes
3 answers

How to connect kafka topic with web endpoint using Faust Python package?

I have a simple app, with two functions, one for listening to topic and other for web endpoint. I want to create server side event streaming (SSE) i.e text/event-stream, so that on client end I could listen to it using EventSource. I have the…
Maverick
  • 2,738
  • 24
  • 91
  • 157
12
votes
1 answer

aiohttp.client_exceptions.ClientOSError: [WinError 10054] An existing connection was forcibly closed by the remote host

I am trying aiohttp and asyncio first time and getting error like [WinError 10054] An existing connection was forcibly closed by the remote host but same url when i fetch with requests it working properly.so what does this error mean and how to…
gaurav
  • 1,281
  • 1
  • 13
  • 25