@@ -84,7 +84,7 @@ class Assembler:
8484 # coverage reports incorrectly: "line NN didn't jump to the function exit"
8585 def __init__ ( # pragma: no cover
8686 self ,
87- high : int = 16 ,
87+ high : int | None = None ,
8888 low : int | None = None ,
8989 pause : Callable [[], Any ] = lambda : None ,
9090 resume : Callable [[], Any ] = lambda : None ,
@@ -96,12 +96,15 @@ def __init__( # pragma: no cover
9696 # call to Protocol.data_received() could produce thousands of frames,
9797 # which must be buffered. Instead, we pause reading when the buffer goes
9898 # above the high limit and we resume when it goes under the low limit.
99- if low is None :
99+ if high is not None and low is None :
100100 low = high // 4
101- if low < 0 :
102- raise ValueError ("low must be positive or equal to zero" )
103- if high < low :
104- raise ValueError ("high must be greater than or equal to low" )
101+ if high is None and low is not None :
102+ high = low * 4
103+ if high is not None and low is not None :
104+ if low < 0 :
105+ raise ValueError ("low must be positive or equal to zero" )
106+ if high < low :
107+ raise ValueError ("high must be greater than or equal to low" )
105108 self .high , self .low = high , low
106109 self .pause = pause
107110 self .resume = resume
@@ -256,13 +259,21 @@ def put(self, frame: Frame) -> None:
256259
257260 def maybe_pause (self ) -> None :
258261 """Pause the writer if queue is above the high water mark."""
262+ # Skip if flow control is disabled
263+ if self .high is None :
264+ return
265+
259266 # Check for "> high" to support high = 0
260267 if len (self .frames ) > self .high and not self .paused :
261268 self .paused = True
262269 self .pause ()
263270
264271 def maybe_resume (self ) -> None :
265272 """Resume the writer if queue is below the low water mark."""
273+ # Skip if flow control is disabled
274+ if self .low is None :
275+ return
276+
266277 # Check for "<= low" to support low = 0
267278 if len (self .frames ) <= self .low and self .paused :
268279 self .paused = False
0 commit comments