def handle(self): stream = self.request.makefile() stream.client_address = self.client_address while True: try: packet, stream = Packet.deserialize(stream) except: break self.server.trigger('data', packet, stream)
def test_round_trip(): from pyec.packet import Packet, Int import random import io class TestPacket(Packet): x = Int() y = Int() for _ in range(400): p = TestPacket(random.randrange(100000), random.randrange(100000)) assert Packet.deserialize(io.BytesIO(p.serialize())) == p