def read_response(self): packet = read_packet(self._connfd) if packet.header.ptype != CCNET_MSG_RESPONSE: raise RuntimeError('Invalid Response') code, code_msg, content = parse_response(packet.body) return Response(code, code_msg, content)
def main_loop(self): while True: pkt = read_packet(self._connfd) import gevent gevent.spawn(self.handle_packet, pkt)