asyncpg
asyncpg copied to clipboard
TLSUpgradeProto: don't set multiple results for an event
In the case of a misbehaving server, the client may receive more than one byte in separate data_received() invocations from the server. While we can't do much sane with this, we should handle it gracefully and not crash with asyncio.InvalidStateError when trying to set another result on the event.
Fixes #729
This appears to be a duplicate of https://github.com/MagicStack/asyncpg/pull/1031, though it's a nicer version and comes with tests. Previously @elprans did not like the approach.