Comments (5)
At a glance, if I've understood that correctly, changing the parameter would just stop you from receiving the full response (as that method is only going to be called when new data is received). Isn't the problem more that it shouldn't be calling that method with too much data? As you are using the streaming API, I'd expect it to only receive a few KBs of data each time and call that decompress method with it each time. So, if you see high memory usage, I wonder if the issue is actually with the streaming API instead...
@mykola-mokhnach might have some ideas as they last worked on the compression code.
from aiohttp.
At a glance, if I've understood that correctly, changing the parameter would just stop you from receiving the full response (as that method is only going to be called when new data is received). Isn't the problem more that it shouldn't be calling that method with too much data? As you are using the streaming API, I'd expect it to only receive a few KBs of data each time and call that decompress method with it each time. So, if you see high memory usage, I wonder if the issue is actually with the streaming API instead...
@mykola-mokhnach might have some ideas as they last worked on the compression code.
For example 1Kb after ungzip will be about 1Mb or bigger. Because the buffer is for incoming from the socket, not after ungzip.
from aiohttp.
Right, good point. So, if it's data with a very high compression ratio it could become a problem. I suspect this would still need some refactoring in order to get it to return the full data.
i.e. Instead of something like:
for chunk in data_received:
yield decompress(chunk)
we'd need something more along the lines of:
for chunk in data_received:
while chunk:
result = decompress(chunk)
yield result.data
chunk = result.unconsumed_tail
from aiohttp.
Feel free to try and create a PR. I'd assume this would be fine changing the default behaviour, as the purpose of the streaming API is to limit memory usage, so this looks like an oversight to me.
Ideally, this would need to be implemented in the brotli decompressor too.
from aiohttp.
@Dreamsorcerer thank you! I'll work on it. I created issue in brotli. it doesn't have the option.
from aiohttp.
Related Issues (20)
- request tuto/method how to debug unclosed sessions on exit HOT 7
- 404 returned if only compressed file exists
- loop.run_forever terminated by exception HOT 4
- web_ws - Can't close tcp socket when receiving a close message from client. HOT 18
- Large payloads lead to BrokenPipe inside a request context manager HOT 1
- OSError : bind(): bad family HOT 1
- Error upon attempt to download https://dieunbestechlichen.com/feed HOT 3
- aiohttp 3.9.3 fails to install on Python 3.13.0a4 HOT 4
- aiohttp.web listens both TCP and Unix socket if `-U` has been supplied HOT 4
- TCPConnector / enable `limit_per_url` HOT 5
- Stability issues with gunicorn --max-requests HOT 11
- ClientSession cannot reuse connection pool HOT 4
- Using underscore to name a field in a named tuple HOT 2
- Request Pynacl Encryption Middleware HOT 13
- ASGI support HOT 4
- tests/test_pytest_plugin.py::test_aiohttp_plugin fails on Alpine Linux (python 3.11 and python 3.12) HOT 12
- ERROR: aiohttp has an invalid wheel, .dist-info directory 'yarl-1.9.4.dist-info' does not start with 'aiohttp' HOT 2
- "Unclosed client session" when initialization fails HOT 2
- Expired cookies not listed in the response cookies HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiohttp.