Questions tagged [httpx]

use this tag for python-httpx related questions.

HTTPX is a fully featured HTTP client for Python 3, which provides sync and async APIs, and support for both HTTP/1.1 and HTTP/2. For more details, please check https://www.python-httpx.org/

38 questions
3
votes
1 answer

Yielding asyncio generator data back from event loop possible?

I would like to read from multiple simultanous HTTP streaming requests inside coroutines using httpx, and yield the data back to my non-async function running the event loop, rather than just returning the final data. But if I make my async…
gwtwod
  • 33
  • 4
3
votes
0 answers

Python asyncio vs ThreadPoolExecutor - inconsistent results for a purely I/O based task

I've recently come across the problem where one needs to fetch a list of URLs as quickly as possible. So naturally, I set up a small test to see what works best. Approach 1 - asyncio async def test_async(): async with httpx.AsyncClient() as…
Dev Aggarwal
  • 3,725
  • 1
  • 24
  • 35
2
votes
1 answer

Python: Cannot install googletrans

I try to install googletrans https://pypi.org/project/googletrans/ by running this command as adviced: $ pip install googletrans but I always get same error both at python 3.5 and python 2.7: Collecting googletrans Using cached…
2
votes
1 answer

Parallel requests block infinitely after exactly 100 requests using asyncio

I've tried using both httpx and aiohttp, and both have this hard-coded limit. import asyncio import aiohttp import httpx async def main(): client = aiohttp.ClientSession() # client = httpx.AsyncClient(timeout=None) coros = [ …
Dev Aggarwal
  • 3,725
  • 1
  • 24
  • 35
2
votes
1 answer

uploading multiple files UploadFiles FastAPI

Example Here's my code: from typing import List from fastapi import FastAPI, File, UploadFile import asyncio import concurrent.futures app = FastAPI() @app.post("/send_images") async def update_item( files: List[UploadFile] = File(...), ): …
1
vote
1 answer

fastapi throws 400 bad request when I upload a large file

I provisioned and configured a Fedora 34 vm on VirtualBox with 2048 MB RAM to serve this FastAPI application on localhost:7070. The full application source code and dependency code and instructions are here. Below is the smallest reproducible…
1
vote
0 answers

aiohttp - Error: 400, message='invalid character in header'

I've started working with AioHttp to use async code in requests. However, I've found that I encounter many pages that don't return a response. Instead I get: Error: 400, message='invalid character in header' I've looked online for a way past this…
cakelover
  • 111
  • 6
1
vote
1 answer

When using Python asyncio corurrent send network request, how to make coroutine prefer continue to handle response first, not send a new request?

If I want to request a API 1000 times (send network request and handle response), it will begin to handle response after sending all 1000 request first, and then handle response. Can I tell asyncio prefer to return back await position code if it's…
LudwigWS
  • 13
  • 4
1
vote
0 answers

How to seperate async requests from the underlying socket request

I'm calling the following JSON-EndPoint in order to retrieve the following value of reference_number. Using a normal for loop for 3 requests, I've been able to receive a new token per each request as below: import httpx for _ in range(3): r =…
1
vote
2 answers

how to use httpx.AsyncClient as class member, and close asynchronously

I want to use http client as a class member, but del function could not call await client.aclose(). e.g.: import httpx class Foo(object): def __init__(self): self.client = httpx.AsyncClient() def __del__(self): await…
whi
  • 2,292
  • 5
  • 26
  • 33
1
vote
0 answers

How can I use httpx to upload a file to S3 using a presigned url (PUT method)

As httpx aims to be compatible with the requests API wherever possible i tried the following based on this answer: with open(local_file, 'rb') as f: response = httpx.put(s3_presigned_url, data=f) This returns a 501 response from S3 with the…
agrav
  • 11
  • 3
1
vote
0 answers

Why isn't my HTTP proxy connecting to an HTTPS website?

I am trying to understand why a proxy is not connecting to the website, but displays my IP instead import httpx import asyncio proxies = {"http": "http://34.91.135.38:80"} async def main(): async with httpx.AsyncClient(proxies=proxies) as…
jad01
  • 11
  • 1
1
vote
1 answer

How does urllib.request differ from curl or httpx in behaviour? Getting a 401 in a request to the Google Container Registry

I am currently working on some code to interact with images on the Google Container Registry. I have working code both using plain curl and also httpx. I am trying to build a package without 3rd party dependencies. My curiosity is around a…
0
votes
0 answers

Python httpx session instantiated inside class vs context manager

I understand that the recommended way to use httpx.Client() is as a context manager that will ensure the connections get properly cleaned-up upon exiting the with block. But let us suppose I want to write a class that will instantiate an…
noob
  • 87
  • 6
0
votes
2 answers

python asyncio & httpx

I am very new to asynchronous programming and I was playing around with httpx. I have the following code and I am sure I am doing something wrong - just don't know what it is. There are two methods, one synchronous and other asynchronous. They…
ukhan
  • 51
  • 1
  • 10
1
2 3