@@ -81,8 +81,7 @@ class Assembler:
81
81
82
82
"""
83
83
84
- # coverage reports incorrectly: "line NN didn't jump to the function exit"
85
- def __init__ ( # pragma: no cover
84
+ def __init__ (
86
85
self ,
87
86
high : int | None = None ,
88
87
low : int | None = None ,
@@ -155,15 +154,15 @@ async def get(self, decode: bool | None = None) -> Data:
155
154
# until get() fetches a complete message or is canceled.
156
155
157
156
try :
158
- # First frame
157
+ # Fetch the first frame.
159
158
frame = await self .frames .get (not self .closed )
160
159
self .maybe_resume ()
161
160
assert frame .opcode is OP_TEXT or frame .opcode is OP_BINARY
162
161
if decode is None :
163
162
decode = frame .opcode is OP_TEXT
164
163
frames = [frame ]
165
164
166
- # Following frames, for fragmented messages
165
+ # Fetch subsequent frames for fragmented messages.
167
166
while not frame .fin :
168
167
try :
169
168
frame = await self .frames .get (not self .closed )
@@ -230,7 +229,7 @@ async def get_iter(self, decode: bool | None = None) -> AsyncIterator[Data]:
230
229
# If get_iter() raises an exception e.g. in decoder.decode(),
231
230
# get_in_progress remains set and the connection becomes unusable.
232
231
233
- # First frame
232
+ # Yield the first frame.
234
233
try :
235
234
frame = await self .frames .get (not self .closed )
236
235
except asyncio .CancelledError :
@@ -247,7 +246,7 @@ async def get_iter(self, decode: bool | None = None) -> AsyncIterator[Data]:
247
246
# Convert to bytes when frame.data is a bytearray.
248
247
yield bytes (frame .data )
249
248
250
- # Following frames, for fragmented messages
249
+ # Yield subsequent frames for fragmented messages.
251
250
while not frame .fin :
252
251
# We cannot handle asyncio.CancelledError because we don't buffer
253
252
# previous fragments — we're streaming them. Canceling get_iter()
@@ -280,22 +279,22 @@ def put(self, frame: Frame) -> None:
280
279
281
280
def maybe_pause (self ) -> None :
282
281
"""Pause the writer if queue is above the high water mark."""
283
- # Skip if flow control is disabled
282
+ # Skip if flow control is disabled.
284
283
if self .high is None :
285
284
return
286
285
287
- # Check for "> high" to support high = 0
286
+ # Check for "> high" to support high = 0.
288
287
if len (self .frames ) > self .high and not self .paused :
289
288
self .paused = True
290
289
self .pause ()
291
290
292
291
def maybe_resume (self ) -> None :
293
292
"""Resume the writer if queue is below the low water mark."""
294
- # Skip if flow control is disabled
293
+ # Skip if flow control is disabled.
295
294
if self .low is None :
296
295
return
297
296
298
- # Check for "<= low" to support low = 0
297
+ # Check for "<= low" to support low = 0.
299
298
if len (self .frames ) <= self .low and self .paused :
300
299
self .paused = False
301
300
self .resume ()
0 commit comments