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:
140140 :return: bytes actually read
141141 """
142142 await self .rw_lock .acquire_read ()
143+ payload : bytes = b""
143144 try :
144145 if n is not None and n < 0 :
145146 raise ValueError (
@@ -180,12 +181,12 @@ async def read(self, n: int | None = None) -> bytes:
180181 "This should never happen."
181182 ) from error
182183 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 )
186187 finally :
187188 await self .rw_lock .release_read ()
188- return b""
189+ return payload
189190
190191 async def write (self , data : bytes ) -> None :
191192 """
You can’t perform that action at this time.
0 commit comments