Skip to content

Commit

Permalink
Merge pull request #112 from theunkn0wn1/fix/111
Browse files Browse the repository at this point in the history
Resolve Client.whois deadlock
  • Loading branch information
theunkn0wn1 authored Feb 2, 2019
2 parents 817e715 + b589678 commit 7f0ccde
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions pydle/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. """
Expand All @@ -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()
Expand Down Expand Up @@ -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. """
Expand Down

0 comments on commit 7f0ccde

Please sign in to comment.