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

Python3 threads or aiohttp?

I want to create a program that can fetch 100's of webpages and return their content. I can do this with a simple python script now: import requests urls = [...] data = [] for url in urls: content = requests.get(url).content …
0
votes
1 answer

asyncio tasks using aiohttp.ClientSession

I'm using python 3.7 and trying to make a crawler that can go multiple domains asynchronously. I'm using for this asyncio and aiohttp but i'm experiencing problems with the aiohttp.ClientSession. This is my reduced code: import aiohttp import…
vladimir.gorea
  • 641
  • 1
  • 8
  • 27
0
votes
2 answers

Closing ClientSession when keyboard interrupt

I am making a discord bot with python. When a user types a command, this bot brings data from url and shows it. I use aiohttp for asynchronous http request, but documentation of discord.py says, Since it is better to not create a session for every…
Ellisein
  • 878
  • 6
  • 17
0
votes
0 answers

aiohttp - unable to serve requests asyncronously

I am playing with aiohttp lib, trying to create a simple async handler that sleeps and then returns. import asyncio from aiohttp import web async def handle(request): print('before sleep') await asyncio.sleep(3) print(' after…
kurtgn
  • 8,140
  • 13
  • 55
  • 91
0
votes
0 answers

Catching exceptions within asyncio coroutine

I have a script to download files using asyncio. The problem I am facing is when an exception is rised, it is catched within the task but the task is resumed and start the loop again In downloader a loop for pagination has been implmented, the…
user2270655
0
votes
2 answers

python 3.6 asyncio error not iterable while not iterating through async object

I have a class that create a url and some json to execute in a post method that looks like that and I was following this guide import vk_api from vk_api.execute import VkFunction import time from datetime import datetime import numpy as np import…
nexla
  • 434
  • 7
  • 20
0
votes
1 answer

aiohttp php like arrays in post

I have recieved array: MultiDict({'data[0]': 'test', 'data[1]': 'test', 'data[2]': 'test', 'hash': 'b5a1f45733f0949ed80f1ef4eaef5454667e4eeb0b77233e15a796e6c91c088b'}) I need to iterate datas like php`s sorted array: foreach ($_POST["data"] as…
eri
  • 3,133
  • 1
  • 23
  • 35
0
votes
0 answers

downloading images with aiohttp get stuck after some iteration

I am using aiohttp to download some image files asynchronously. my code is: async def save_message_images(self, message_data, channel): async with aiohttp.ClientSession() as session: image_links = [] for i, link in…
hamid
  • 694
  • 1
  • 8
  • 20
0
votes
1 answer

How to post group of requests to 2 urls with aiohttp

I have 2 URLs and 60k+ requests. Basically, I need to post every request to both URLs, then compare their responses, but not to wait for the response to post another request. I've tried to do it with aiohttp and asyncio import asyncio import…
Alexander
  • 51
  • 8
0
votes
2 answers

How to implement callbacks for SIGTERM and SIGINT signals with aiohttp

I'm trying to implement a graceful shutdown to my web server ran by aiohttp. I need it to gracefully close and clean redis and DB connections. For what I ve seen in the different documents talking about this I ve registered a callback with…
R.E.B Hernandez
  • 147
  • 2
  • 9
0
votes
0 answers

How to use aiohttp with ThreadPoolExecutor?

I now have this code: def parse_url(i): url = f"https://www.python.org/dev/peps/pep-{i}/" print(f"Started {str(i)}") r = requests.get(url) print(f"Ended {str(i)}") return r.content async def get_urls(executor): loop =…
Fominykh Maxim
  • 485
  • 1
  • 6
  • 20
0
votes
0 answers

How can I return the response before the execution of the function using Aiohttp library?

Actually I want to return a response whenever a request is fired and then execute the task asynchronously so that the client has to not wait for a long to get the response.For that, I am using "Aiohttp" library as I want to perform async tasks. Can…
jack
  • 101
  • 1
  • 9
0
votes
0 answers

How to send messages from aiohttp service to SQS-queue?

I need to send messages to SQS queue from aiohttp service. I read documentation of aiobotocore and all examples, but I don`t see anything how to send messages same as postgres from aipg for example. async def pg_engine(app): app['pg_engine'] =…
0
votes
1 answer

aiohttp - running client example "RuntimeError: SSL is not supported"

I'm just trying to go through the aiohttp examples but I get the error with the first one: import aiohttp import asyncio async def fetch(session, url): async with session.get(url) as response: return await response.text() async def…
vladimir.gorea
  • 641
  • 1
  • 8
  • 27
0
votes
0 answers

How to make Async Api Requests in Python, properly?

I am not an expert in python so I am having trouble trying to make async api requests, it's throwing "RuntimeError: Event loop is closed". I make lots of requests to an API and sometimes it returns status code 429 (too many requests), so what I want…