Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make DEFAULT_LIMIT monkey patchable #4696

Closed
wants to merge 10 commits into from
1 change: 1 addition & 0 deletions CHANGES/4696.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make aiohttp.streams.DEFAULT_LIMIT changeable allowing a workaround for long lines
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ Sean Hunt
Sebastian Acuna
Sebastian Hanula
Sebastian Hüther
Sebastian Gerber
Sebastien Geffroy
SeongSoo Cho
Sergey Ninua
Expand Down
12 changes: 6 additions & 6 deletions aiohttp/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ class StreamReader(AsyncStreamReaderMixin):
total_bytes = 0

def __init__(self, protocol: BaseProtocol,
*, limit: int=DEFAULT_LIMIT,
*, limit: Optional[int]=None,
timer: Optional[BaseTimerContext]=None,
loop: asyncio.AbstractEventLoop) -> None:
loop: Optional[asyncio.AbstractEventLoop]=None) -> None:
self._protocol = protocol
self._low_water = limit
self._high_water = limit * 2
self._low_water = limit if limit is not None else DEFAULT_LIMIT
self._high_water = self._low_water * 2
if loop is None:
loop = asyncio.get_event_loop()
self._loop = loop
Expand Down Expand Up @@ -601,12 +601,12 @@ class FlowControlDataQueue(DataQueue[_T]):
It is a destination for parsed data."""

def __init__(self, protocol: BaseProtocol, *,
limit: int=DEFAULT_LIMIT,
limit: Optional[int]=None,
loop: asyncio.AbstractEventLoop) -> None:
super().__init__(loop=loop)

self._protocol = protocol
self._limit = limit * 2
self._limit = limit * 2 if limit is not None else DEFAULT_LIMIT
spacemanspiff2007 marked this conversation as resolved.
Show resolved Hide resolved

def feed_data(self, data: _T, size: int=0) -> None:
super().feed_data(data, size)
Expand Down