def dispatch_packet(self, packet): if not getattr(packet, 'no_log', False): self.log.debug('received %r', packet) packet_type = packet.type method = self._packet_handlers.get(packet_type, None) if method is None: self.on_missing_handler(packet) return None arg_spec = inspect.getargspec(method) args, kwargs = packet.get_method_args(len(arg_spec[0])) try: inspect.getcallargs(method, packet_type, *args, **kwargs) except TypeError as e: raise PacketFormatError(text_type(e)) try: ret = method(packet_type, *args, **kwargs) except Exception: raise else: return ret
def on_error(self, app, error): """Called on WS error""" self.ready_event.set() if error: self.log.error(text_type(error))