|
7 | 7 |
|
8 | 8 | from cloudbot.client import Client |
9 | 9 | from cloudbot.event import Event, EventType |
| 10 | +from cloudbot.util import async_util |
10 | 11 |
|
11 | 12 | logger = logging.getLogger("cloudbot") |
12 | 13 |
|
@@ -218,8 +219,7 @@ def _send(self, line): |
218 | 219 | :type line: str |
219 | 220 | """ |
220 | 221 | logger.info("[{}] >> {}".format(self.name, line)) |
221 | | - asyncio.async(self._protocol.send(line), loop=self.loop) |
222 | | - |
| 222 | + async_util.wrap_future(self._protocol.send(line), loop=self.loop) |
223 | 223 |
|
224 | 224 | @property |
225 | 225 | def connected(self): |
@@ -272,14 +272,14 @@ def connection_lost(self, exc): |
272 | 272 | # we've been closed intentionally, so don't reconnect |
273 | 273 | return |
274 | 274 | logger.error("[{}] Connection lost: {}".format(self.conn.name, exc)) |
275 | | - asyncio.async(self.conn.connect(), loop=self.loop) |
| 275 | + async_util.wrap_future(self.conn.connect(), loop=self.loop) |
276 | 276 |
|
277 | 277 | def eof_received(self): |
278 | 278 | self._connected = False |
279 | 279 | # create a new connected_future for when we are connected. |
280 | 280 | self._connected_future = asyncio.Future(loop=self.loop) |
281 | 281 | logger.info("[{}] EOF received.".format(self.conn.name)) |
282 | | - asyncio.async(self.conn.connect(), loop=self.loop) |
| 282 | + async_util.wrap_future(self.conn.connect(), loop=self.loop) |
283 | 283 | return True |
284 | 284 |
|
285 | 285 | @asyncio.coroutine |
@@ -339,7 +339,7 @@ def data_received(self, data): |
339 | 339 | # Reply to pings immediately |
340 | 340 |
|
341 | 341 | if command == "PING": |
342 | | - asyncio.async(self.send("PONG " + command_params[-1]), loop=self.loop) |
| 342 | + async_util.wrap_future(self.send("PONG " + command_params[-1]), loop=self.loop) |
343 | 343 |
|
344 | 344 | # Parse the command and params |
345 | 345 |
|
@@ -406,7 +406,7 @@ def data_received(self, data): |
406 | 406 | irc_prefix=prefix, irc_command=command, irc_paramlist=command_params, irc_ctcp_text=ctcp_text) |
407 | 407 |
|
408 | 408 | # handle the message, async |
409 | | - asyncio.async(self.bot.process(event), loop=self.loop) |
| 409 | + async_util.wrap_future(self.bot.process(event), loop=self.loop) |
410 | 410 |
|
411 | 411 | # Channel Commands |
412 | 412 | # NOTICE #chan :Text |
|
0 commit comments