Commit f6afb9c3 authored by Elizabeth Myers's avatar Elizabeth Myers 💬
Browse files

Merge branch 'fix-asyncio' into 'master'

Quick hacky fix for asyncio

There may be a reason we weren't creating the `_call_task` in `__init__`, but I'm not sure what it was.

See merge request !6
parents 21e7a1ce 8a94f6cb
......@@ -49,7 +49,10 @@ class IRCProtocol(IRCBase, asyncio.Protocol):
def __init__(self, *args, **kwargs):
self._call_queue = asyncio.Queue()
self._call_task = None
# Start the task queue
self._call_task = asyncio.async(self._process_queue())
self._call_task.add_done_callback(self._process_queue_exit)
super().__init__(*args, **kwargs)
......@@ -70,10 +73,6 @@ class IRCProtocol(IRCBase, asyncio.Protocol):
:returns:
An asyncio coroutine representing the connection.
"""
# Start the task queue
self._call_task = asyncio.async(self._process_queue())
self._call_task.add_done_callback(self._process_queue_exit)
loop = asyncio.get_event_loop()
return loop.create_connection(lambda: self, self.server, self.port,
ssl=self.ssl)
......@@ -139,7 +138,6 @@ class IRCProtocol(IRCBase, asyncio.Protocol):
def _process_queue_exit(self, future):
_logger.critical("Process queue died!")
self._call_task = None
self._call_queue = asyncio.Queue()
self.close()
......@@ -149,7 +147,7 @@ class IRCProtocol(IRCBase, asyncio.Protocol):
If no args are passed in, and the signal is in a deferred state, the
arguments from the last call_event will be used.
"""
if self._call_task and self._call_task.exception():
if self._call_task.done() and self._call_task.exception():
# Exception raised, let's get out of here!
raise self._call_task.exception()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment