1,720 questions
0
votes
0
answers
20
views
async posting just hangs
I'm using aiohttp to post multiple times, but I find an issue that means that I never get beyond the first post. Code then hangs for a while and produces the below error.
async def posted(URL, payload)...
0
votes
0
answers
31
views
aiohttp post request h11._util.LocalProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_BODY [duplicate]
I'm using aiohttp==3.10.10 with python 3.8
For context I'm running a fastAPI app and on every request the app receives it creates an async background task to send a post request to another external ...
0
votes
0
answers
24
views
aiohttp showing 403 error but requests.get giving 200 response
I'm using aiohttp to asynchronously retrieve a price from a url. Previously, I used requests.get for synchronous reading. I can successfully fetch the data with requests.get, but the same url gives a ...
1
vote
0
answers
46
views
RuntimeError: "Timeout context manager should be used inside a task" with pytest-asyncio but works in direct Python execution
Using asyncio and aiohttp in an application I'm building and can't seem to figure out how to get pytest playing nicely. When I use pytest I always get a
RuntimeError: Timeout context manager should ...
0
votes
1
answer
44
views
aiohttp session request fail
I try to get data from Jira API with aiohttp session request and it's failed with 401.
Yes the problem is providing login and password (not token), but its work with requests.
This work:
r = requests....
0
votes
1
answer
160
views
SSL and aiohttp: disable SSL verification do not work on python 3.12
I have a request like this from aiohttp:
async with aiohttp.ClientSession(auth=aiohttp.BasicAuth(self.user, self.password), timeout=aiohttp.ClientTimeout(connect=self.timeouts[0], sock_read=self....
0
votes
1
answer
36
views
wait_for asyncio event prevents aiohttp from proper cleanup
I found unintuitive behaviour of asincio.wait_for when waiting for asyncio.Event. Aiohttp cleanup is not working in this case:
import asyncio
import logging
from aiohttp import web
async def ctx(app):...
0
votes
0
answers
44
views
Optimising requests in my Python code using asynchronicity
I’m currently attempting to optimise a Python script I wrote that makes multiple HTTP requests using the aiohttp library. I want to take advantage of asynchronous programming in order to handle ...
1
vote
2
answers
103
views
How to use aiohttp with apscheduler?
I would like to fetch several web pages periodically all within the same aiohttp.ClientSession(). Here is what I have got so far. The URLs need to remain within the jobs, because some other URLs will ...
1
vote
1
answer
34
views
Append function calls to asyncio.gather until condition is fullfilled?
I am downloading folders with aiohttp. However i want to stop downloading when the hdd has only 200gb of free space: Right now I am doing it like this:
async def main():
split_list = numpy....
1
vote
0
answers
49
views
Error 'Server Disconnected' when using SSH Proxy Tunnel with aiohttp in Python
I'm trying to make requests to an endpoint using a Python script that connects to an SSH proxy tunnel. I set up the SSH tunnel using the following command:
sshpass -p "<my_pass>" ssh -...
0
votes
1
answer
41
views
Fetching multiple urls with aiohttp from a loop/generator
All examples I saw for fetching multiple urls with aiohttp suggest to to the following:
async def fetch(session, url):
async with session.get(url, ssl=ssl.SSLContext()) as response:
return ...
1
vote
1
answer
38
views
aiohttp behaviour when not reading body
In my current development, I am sending a request to 50-100 different servers at the same time with aiohttp, and I am in no need to read the body (only need status_code and headers). I also cannot use ...
0
votes
0
answers
19
views
CERTIFICATE_VERIFY_FAILED when running python-script with shazamio on Mac?
i try to run the following code on a Mac-Computer:
import asyncio
from shazamio import Shazam
import os, sys
import pprint
path = os.path.abspath(os.path.dirname(sys.argv[0]))
fn = os.path.join(path,...
2
votes
2
answers
115
views
Memory Leak in Asynchronous HTTP Requests with aiohttp in Django
I'm encountering a memory leak issue in my Django application that utilizes aiohttp for making asynchronous HTTP requests. I've set up a function to fetch data from a REST API, but despite my attempts ...
1
vote
1
answer
111
views
Closing a httpx client results in a "RuntimeError: Event loop is closed"
I need to maintain a persistent httpx client in my code to utilize its connection pool throughout the lifespan of my application. Below is a simplified version of my implementation:
import asyncio
...
0
votes
0
answers
47
views
aiohttp: Ignore "Data after `Connection: close`" error
In a domotic context, I'm trying to interact with the Python aiohttp library with a device that has a buggy HTTP server. On some of its endpoints, this HTTP server returns a Connection: close header ...
0
votes
0
answers
45
views
aiohttp adds ~100 seconds latency?
I am sending a basic post request from a client to a server. The logs on my server show that the response took 9.41 seconds, but the logs on the client show that it took ~100 seconds.
Here is my code
...
0
votes
1
answer
50
views
asyncio server does not cancels request even if aiohttp.ClientSession exceeds its timeout
The final goal is to cancel request on server side if client exceeds its timeout.
The code related to start the server:
def run_server_loop(
routes: web.RouteTableDef,
shutdown_state: ...
2
votes
0
answers
40
views
Request with proxy can't reach FastAPI webserver
I want to test my HTTP downloaders in GitLab CI/CD. So I chose FastAPI as the web server to which downloaders will be tested.
Currently, I am trying to make it work locally, but the request always ...
0
votes
1
answer
76
views
Python aiohttp - how to close a session?
I am totally new to async. I'm having trouble closing connections when trying to make async requests. Here is my code:
def async_aiohttp_get_all(self, urls):
"""
performs ...
1
vote
1
answer
89
views
Asyncio Proxy Checking
I am writing a script to determine working proxy servers. Everything runs smoothly with the Synchronous class, however, when I want to do this with asynchronous programming, I get very different ...
0
votes
0
answers
119
views
'statusCode': 401, error with aiohttp et asyncio, ChatGPT request
I'm trying to make a simple request using azure.openai chatGPT, i setup a simple code but i always get a 401 return error:
{'statusCode': 401, 'message': 'Unauthorized. Access token is missing, ...
1
vote
0
answers
41
views
Asyncio.ws_connect not receiving a connection closure message
async def _connect_session(self):
websocket_url, headers, cookies = self._get_connect_data()
try:
async with aiohttp.ClientSession(cookies=cookies) as session:
logger.debug(...
0
votes
2
answers
179
views
How do I create a Python API client which executes *some* methods asynchronously in the background?
I have this (example) REST API client:
import requests
class FakeHttpClient:
base_url = "https://api.example.com"
def __init__(self) -> None:
self.session = requests....
0
votes
1
answer
354
views
fastapi service throwing exception 'no running event loop'
I have a fastapi service that is using a library. The library is doing I/O.
I converted the library to be full async. Changed the unit tests, and all the tests pass.
Now when I try to use that library ...
1
vote
1
answer
55
views
Keep getting Asyncio/Aiohttp RuntimeError after code execution
This is part of the code section. I removed all useless stuff... I found out that the Player_Season variable causes this pipeline error. I'm not sure why its causing it. Hasn't been before.
Exception ...
0
votes
1
answer
63
views
How to property handle request with aiohttp
I use aiohttp and send a request like this:
async with session.get(url=url, headers=headers) as res:
src = await res.text()
After that, I handle html code with BeautifulSoup4.
Is it necessary to ...
0
votes
1
answer
176
views
Error when requesting via aio http AttributeError: the 'NoneType' object does not have the 'connect' attribute
I am writing an asynchronous parser http://freelance.habr.com where I iterate through all the tasks for a specific query. I use aio http for requests. During the execution, only some tasks give an ...
2
votes
0
answers
60
views
Parallel requests gets slow when the list grows
I have created an application using FastAPI that basically exposes a POST route and execute few external requests for each incoming request.
The code is really simple:
from fastapi import FastAPI
from ...
0
votes
0
answers
83
views
Aiohttp Ignore Response Headers
I want to get a response from an API using aiohttp.ClientSession().get(), however the API's raw response headers contain an entry that looks something like 'Status Code': 200. This makes aiohttp throw ...
0
votes
0
answers
55
views
aiohttp.ClientSession http request stuck without error
I'm making async http request using aiohttp.ClientSession().
My code gets stuck at line where request is sent. No exception is raised. It just freezes.
Below is my code:
headers = {'Content-Type': '...
0
votes
2
answers
63
views
When should I use await when using aiohttp?
I am new to python and I was studying asyncio/aiohttp but I'm kinda confused when should I use an "await".
It's clear that I use await when I want to wait the response but let's imagine the ...
0
votes
0
answers
64
views
What is the difference in aiohttp default Content-Type vs requests module's defaults?
I am working with an API that requires RSA256 public key POSTed as bytes. I was using requests (at first for testing) and aiohttp (to scale it up for many requests) and noticed a difference that I am ...
0
votes
1
answer
110
views
How to time an aiohttp request
I have an async script that looks partially like:
def main(endpoints):
loop = asyncio.get_event_loop()
loop.run_until_complete(_main(endpoints, loop))
loop.close()
async def _main(...
0
votes
0
answers
21
views
aiohttp will not serve static files, client getting "Empty reply from server"
I'm facing a weird issue where aiohttp seems to work fine aside from actually serving any static files.
I'm testing with curl, and I'm getting "Empty reply from server" when I'm trying to ...
0
votes
2
answers
138
views
How to async instantiate and close a shared aiohttp session in Azure Functions in Python?
I need to use an HTTP client in my Azure Function. I can use aiohttp like this (this is a minimalistic example form the MSFT documentation).
import aiohttp
import azure.functions as func
async def ...
0
votes
1
answer
33
views
Request packets received but not dispatched to aiohttp server
My setup requires a HTTP server listening on a specific IP address, through an OpenVPN connection. To implement the server, I use python 3.11 with the library aiohttp under Ubuntu 22.04.
The issue is ...
0
votes
1
answer
60
views
Why are my async requests almost as slow as sync requests
My code sends async requests to an API but it's not really faster than my code with sync requests. Currently it sends around 50-60 requests and it takes around 1 minute. What am I doing wrong?
#gets ...
0
votes
2
answers
59
views
Timeout Issue with aiohttp but not with Requests
I'm trying to fetch a webpage in Python using two different methods: requests and aiohttp. The requests method works fine, but the aiohttp method results in a timeout. Here's the code:
import asyncio
...
0
votes
1
answer
58
views
aiohttp freeze in ClientSession()
Why ClientSession in async context manager freeze until timeout approximately once in 3-4 runs?
When I await any coroutine from response inside async context manager everything works normal but if I ...
0
votes
0
answers
146
views
How to Retrieve Transaction Data for a Specific Cosmos Address When API Returns No Transactions?
I'm attempting to retrieve transaction data for a specific address on the Cosmos blockchain using Python and aiohttp. The address in question shows 61 transactions on Mintscan, but when querying the ...
0
votes
1
answer
28
views
retrieve full headers and url with params in the case of any aiohttps exception where the request is contructed
I would like to access the full request data including automatic headers and the url with query params without this hacky global variable. In my actual use case, Headers may be passed either to the ...
1
vote
1
answer
220
views
Event loop is closed Python Async
I've built an email script , utilising a user's app key from google to get access to their email. However when i run the script i get the error 'Runtime Error: event loop is closed.
On initial ...
0
votes
0
answers
22
views
Skip TLS Handshake certificate to save Proxy bandwidth
My proxy is charging me for the whole request including TLS handshake -- basically anything that goes through their servers. (Which is fair I guess)
Now when I was debugging my requests, they weigh ...
0
votes
0
answers
80
views
Different responses to the same requests (curl, python aiohttp) on the server and on the local host
I have a parser written in Python (aiohttp, bs4). One of the functions of the parser is to access a file by a link (example: https://modsfire.com/d/Mwv01aESgj73zx7).
import aiohttp
import yarl
import ...
1
vote
1
answer
255
views
aiohttp showing 403 Forbidden but requests.get giving 200 OK response
I'm using aiohttp to asynchronously scrap some price from an url.
Before, I used requests.get to synchronously do the same.
I am able successfully able to scrap using requests.get but the same URL ...
0
votes
1
answer
57
views
aiohttp client methods being called from aiohttp server cause RuntimeError
I'm trying to create a payment microservice with following layout:
The client side is working fine until it comes to use aiohttp client methods in aiohttp server side.
I have a class which creates an ...
0
votes
0
answers
48
views
aiohttp with proxy and cookies not working
I have been attempting to learn how to use aiohttp for a while to make requests asynchronously. I have been stuck in making a request that uses both cookies and proxies on it.
This is my current code:
...
0
votes
0
answers
99
views
RuntimeError: Event loop is closed when integrating Telegram with Rasa chatbot
I am trying to integrate Telegram with my Rasa chatbot, but I am encountering following error --> RuntimeError: Event loop is closed. It appears that the event loop in asyncio is closed, causing ...