protocol¶
-
class
async_patterns.protocol.
Protocol
(loop)[source]¶ Derives
asyncio.Protocol
. Interprets incoming and outgoing data as object instances satisfying the packet protocol (see below). Schedules execution of the packet call function for incoming packets.A unique id is added to outgoing packets. A future is also created for each outgoing packet. The receiving end can construct a packet and set the
response_to
attribute to this id and send the new packet back to this protocol. This protocol will see theresponse_to
attribute and assign the response packet as the result of the future.packet protocol
class Packet: async def __call__(self, protocol): # protocol is this instance pass
-
connection_lost
(exc)[source]¶ Called when the connection is lost or closed.
The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed).
-