Skip to content

Commit f7118a4

Browse files
committed
Unpack subpackets asynchronously even when we read out their data ahead of time
1 parent b099b76 commit f7118a4

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎pak/packets/subpacket.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,12 @@ async def _unpack_async(cls, reader, *, ctx):
295295
packet_cls = cls.subpacket_cls
296296

297297
if header.has_field("size"):
298-
# NOTE: We use synchronous 'unpack' here
299-
# because we read the data out ahead of time.
300-
return packet_cls.unpack(await reader.readexactly(header.size), ctx=ctx.packet_ctx)
298+
# NOTE: We could use synchronous 'unpack' here
299+
# because we read the data out ahead of time,
300+
# however I would worry about how that would
301+
# interface with custom types which do not
302+
# implement the synchronous unpacking API.
303+
return await packet_cls.unpack_async(await reader.readexactly(header.size), ctx=ctx.packet_ctx)
301304

302305
return await packet_cls.unpack_async(reader, ctx=ctx.packet_ctx)
303306

0 commit comments

Comments
 (0)