File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
libp2p/stream_muxer/mplex Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ async def read(self, n: int | None = None) -> bytes:
140
140
:return: bytes actually read
141
141
"""
142
142
await self .rw_lock .acquire_read ()
143
+ payload : bytes = b""
143
144
try :
144
145
if n is not None and n < 0 :
145
146
raise ValueError (
@@ -180,12 +181,12 @@ async def read(self, n: int | None = None) -> bytes:
180
181
"This should never happen."
181
182
) from error
182
183
self ._buf .extend (self ._read_return_when_blocked ())
183
- payload = self ._buf [:n ]
184
- self ._buf = self ._buf [len (payload ) :]
185
- return bytes (payload )
184
+ chunk = self ._buf [:n ]
185
+ self ._buf = self ._buf [len (chunk ) :]
186
+ payload = bytes (chunk )
186
187
finally :
187
188
await self .rw_lock .release_read ()
188
- return b""
189
+ return payload
189
190
190
191
async def write (self , data : bytes ) -> None :
191
192
"""
You can’t perform that action at this time.
0 commit comments