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

Build an Async Python function for API

I am creating a module that communicate with an API and I am thinking to create my function with asyncio. Right now my code look like this : def getMethod(self, stuff:str=None): #yes it in a class header = {'Content-Type': 'application/json'} …
Pitchkrak
  • 340
  • 1
  • 3
  • 11
0
votes
1 answer

Using more than 10 thread consumers with an async producer causes the 10th consumer to hog queue

I am trying to implement what seems to be a standard single producer -- multiple consumers pattern with a queue. I work with aiohttp so my producer is async but a library I need to use for consuming is sync so I run consumers in a thread executor…
Alex Bausk
  • 690
  • 5
  • 29
0
votes
1 answer

Why is my consumer working separately from my producer in the queue?

My objective is to call an API asynchronously, and write the results (from each call) into a file (1 call -> 1 file). I thought one way to implement this is using a queue. My intention is to have responses pushed into the queue as soon as they are…
alt-f4
  • 2,112
  • 17
  • 49
0
votes
0 answers

How to perform proper error handling with asyncio and aiohttp?

I am looking for guidance around best practices with asyncio and aiohttp in Python 3. I have a basic scraper but I am not sure how to: Properly implement error handling. More specific around my fetch function. Do I really need the last main…
Ale M.
  • 175
  • 2
  • 3
  • 11
0
votes
0 answers

asyncio task hangs midway

So i am building a scraper which takes a bunch of urls, a success function that will run via celery if that url was fetched successfully and if any error occurs just return and collect the bunch of urls that were not successfull and send them to be…
Dipendra bhatt
  • 729
  • 5
  • 14
0
votes
1 answer

How to connect with multiply websockets using Jupyter notebook

This program on Jupyter notebook connect only with first websocket. What is wrong? session1 = aiohttp.ClientSession() session2 = aiohttp.ClientSession() async with session1.ws_connect('host1') as ws1: async for msg1 in ws1: …
0
votes
1 answer

aiohttp server file upload: request.post UnicodeDecodeError

I have a web service in Flask which processes uploaded binary data: @app.route('/v1/something', methods=['POST']) def v1_something(): for name in request.files: file = request.files[name] file.read() ... Now I'm…
AivanF.
  • 1,134
  • 2
  • 23
  • 52
0
votes
1 answer

When using websockets with aiohttp.web and using Cloudflare's proxy, the websocket connection dies 2~ minutes afterwards with 1006

As the title mentioned.. A little more detailed description of my usage: I use Caddy as reverse proxy for aiohttp. And then Cloudflare in-front of Caddy. This is unrelated to Caddy, because using gray-clouded DNS entry (no proxy from Cloudfare)…
Tarek
  • 3
  • 1
0
votes
1 answer

Instagram API start returning loading page after some calls

I am using the code below to get account information of one thousand instagram accounts using asycnio. In the initial requests the output is correct but after 10-20 calls, instagram starts returning loading page's HTML code. What could I be doing…
Asjad Murtaza
  • 101
  • 1
  • 3
0
votes
0 answers

Aiohttp websocket

I am trying to build a connection using AIOHTTP where from client-side I will get multiple requests continuously. So at the server-side, I have to create WebSocket connection using AIOHTTP so that I can accept multiple messages in a single stable…
Harshit
  • 1
  • 2
0
votes
0 answers

Python aiohttp motorengine

I'm trying to make basic register api but I have some problems with motorengine and aiohttp. Can someone give me examples on how that works ? Here's my code : from motorengine.connection import connect from motorengine.document import Document from…
sectasy
  • 98
  • 2
  • 8
0
votes
0 answers

'aiohttp.ClientSession' cache doesn't work

I hope to use aiohttp.ClientSession cache my connection after be more faster, But i found when i use 'asyncio.sleep' mock the interval time more than 10s the connection will be like first time to connect, the time less than 10s it will be like…
0
votes
1 answer

python aiohttp Client Responses object to io.Text IO Wrapper

I've been stumbling upon a problem with my code, I want to use a library to open a web page's contents and view them in a specific way, after viewing the source code for that lib, I figured out that to use this lib, I needed to use a…
Artrix
  • 149
  • 10
0
votes
2 answers

weird bug when i used asyncpg in my aiohttp app

i started developing my app with aiopg to access data in postgres and everything was OK , i decided to replace it with asyncpg . this is one of my view function : @router.get('/{post}') @aiohttp_jinja2.template("view.html") async def…
Shoobi
  • 88
  • 1
  • 10
0
votes
1 answer

how to check response type aiohttp asyncio python

I have the following method: async def make_request(self, url): async with aiohttp.ClientSession() as session: async with self.limit, session.get(url=url) as response: resp = await response.read() …
Shery
  • 1,808
  • 5
  • 27
  • 51