Skip to content

Commit

Permalink
Unpack subpackets asynchronously even when we read out their data ahe…
Browse files Browse the repository at this point in the history
…ad of time
  • Loading branch information
friedkeenan committed Dec 31, 2024
1 parent b099b76 commit f7118a4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pak/packets/subpacket.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,12 @@ async def _unpack_async(cls, reader, *, ctx):
packet_cls = cls.subpacket_cls

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

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

Expand Down

0 comments on commit f7118a4

Please sign in to comment.