From b589678779906410d84e136d862681e42c14c716 Mon Sep 17 00:00:00 2001 From: theunkn0wn1 Date: Sun, 13 Jan 2019 20:34:23 -0800 Subject: [PATCH] Resolved Deadlock in Client.whois --- pydle/client.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/pydle/client.py b/pydle/client.py index cb61c14..fe0d908 100644 --- a/pydle/client.py +++ b/pydle/client.py @@ -110,9 +110,7 @@ async def connect(self, hostname=None, port=None, reconnect=False, **kwargs): if self.server_tag: self.logger = logging.getLogger(self.__class__.__name__ + ':' + self.server_tag) - # store the handle forever task, so we can cancel it during disconnection - self._handle_forever_task = self.eventloop.create_task(self.handle_forever()) - # ensure_future(self.handle_forever(), loop=self.eventloop) + self.eventloop.create_task(self.handle_forever()) async def disconnect(self, expected=True): """ Disconnect from server. """ @@ -134,13 +132,6 @@ async def _disconnect(self, expected): # Callback. await self.on_disconnect(expected) - # cancel the handle forever task - try: - if self._handle_forever_task: - self._handle_forever_task.cancel() - except asyncio.CancelledError: - # a canceled error is expected here, and is not an error. - self.logger.debug("swallowing expected CancelError") # Shut down event loop. if expected and self.own_eventloop: self.connection.stop() @@ -397,7 +388,8 @@ async def on_data(self, data): while self._has_message(): message = self._parse_message() - await self.on_raw(message) + self.eventloop.create_task(self.on_raw(message)) + async def on_data_error(self, exception): """ Handle error. """