except registered callbacks individually

This commit is contained in:
əlemi 2021-11-12 12:56:44 +01:00
parent 9327b77c3c
commit 1cd94a899a

View file

@ -212,10 +212,16 @@ class Client:
if self.dispatcher.state in self._packet_callbacks: if self.dispatcher.state in self._packet_callbacks:
if Packet in self._packet_callbacks[self.dispatcher.state]: # callback for any packet if Packet in self._packet_callbacks[self.dispatcher.state]: # callback for any packet
for cb in self._packet_callbacks[self.dispatcher.state][Packet]: for cb in self._packet_callbacks[self.dispatcher.state][Packet]:
try:
await cb(packet) await cb(packet)
except Exception as e:
self._logger.exception("Exception while handling callback")
if packet.__class__ in self._packet_callbacks[self.dispatcher.state]: # callback for this packet if packet.__class__ in self._packet_callbacks[self.dispatcher.state]: # callback for this packet
for cb in self._packet_callbacks[self.dispatcher.state][packet.__class__]: for cb in self._packet_callbacks[self.dispatcher.state][packet.__class__]:
try:
await cb(packet) await cb(packet)
except Exception as e:
self._logger.exception("Exception while handling callback")
self.dispatcher.incoming.task_done() self.dispatcher.incoming.task_done()
except asyncio.TimeoutError: except asyncio.TimeoutError: