Browse Source

Fix asyncio.wait calls with deprecated coroutine objects

master
JustAnotherArchivist 3 years ago
parent
commit
bf7f962206
1 changed files with 7 additions and 7 deletions
  1. +7
    -7
      irclog.py

+ 7
- 7
irclog.py View File

@@ -391,7 +391,7 @@ class IRCClientProtocol(asyncio.Protocol):
while True:
self.logger.debug(f'Trying to get data from send queue')
t = asyncio.create_task(self.sendQueue.get())
done, pending = await asyncio.wait((t, self.connectionClosedEvent.wait()), return_when = asyncio.FIRST_COMPLETED)
done, pending = await asyncio.wait({t, asyncio.create_task(self.connectionClosedEvent.wait())}, return_when = asyncio.FIRST_COMPLETED)
if self.connectionClosedEvent.is_set():
break
assert t in done, f'{t!r} is not in {done!r}'
@@ -400,7 +400,7 @@ class IRCClientProtocol(asyncio.Protocol):
now = time.time()
if self.lastSentTime is not None and now - self.lastSentTime < 1:
self.logger.debug(f'Rate limited')
await asyncio.wait({self.connectionClosedEvent.wait()}, timeout = self.lastSentTime + 1 - now)
await asyncio.wait({asyncio.create_task(self.connectionClosedEvent.wait())}, timeout = self.lastSentTime + 1 - now)
if self.connectionClosedEvent.is_set():
break
time_ = self._direct_send(data)
@@ -622,7 +622,7 @@ class IRCClientProtocol(asyncio.Protocol):
self.logger.info('Quitting')
self.lastSentTime = 1.67e34 * math.pi * 1e7 # Disable sending any further messages in send_queue
self._direct_send(b'QUIT :Bye')
await asyncio.wait({self.connectionClosedEvent.wait()}, timeout = 10)
await asyncio.wait({asyncio.create_task(self.connectionClosedEvent.wait())}, timeout = 10)
if not self.connectionClosedEvent.is_set():
self.logger.error('Quitting cleanly did not work, closing connection forcefully')
# Event will be set implicitly in connection_lost.
@@ -684,7 +684,7 @@ class IRCClient:
asyncio.create_task(self._protocol.send_queue()) # Quits automatically on connectionClosedEvent
self.logger.debug('Waiting for connection closure or SIGINT')
try:
await asyncio.wait((connectionClosedEvent.wait(), sigintEvent.wait()), return_when = asyncio.FIRST_COMPLETED)
await asyncio.wait({asyncio.create_task(connectionClosedEvent.wait()), asyncio.create_task(sigintEvent.wait())}, return_when = asyncio.FIRST_COMPLETED)
finally:
self.logger.debug(f'Got connection closed {connectionClosedEvent.is_set()} / SIGINT {sigintEvent.is_set()}')
if not connectionClosedEvent.is_set():
@@ -692,7 +692,7 @@ class IRCClient:
await self._protocol.quit()
except (ConnectionRefusedError, ssl.SSLError, asyncio.TimeoutError) as e:
self.logger.error(str(e))
await asyncio.wait({sigintEvent.wait()}, timeout = 5)
await asyncio.wait({asyncio.create_task(sigintEvent.wait())}, timeout = 5)
if sigintEvent.is_set():
self.logger.debug('Got SIGINT, putting EOF and breaking')
self.messageQueue.put_nowait(messageEOF)
@@ -781,7 +781,7 @@ class Storage:

async def flush_files(self, flushExitEvent):
while True:
await asyncio.wait({flushExitEvent.wait()}, timeout = self.config['storage']['flushTime'])
await asyncio.wait({asyncio.create_task(flushExitEvent.wait())}, timeout = self.config['storage']['flushTime'])
self.logger.debug('Flushing files')
for _, f in self.files.values():
f.flush()
@@ -842,7 +842,7 @@ class WebServer:
await runner.setup()
site = aiohttp.web.TCPSite(runner, self.config['web']['host'], self.config['web']['port'])
await site.start()
await asyncio.wait((stopEvent.wait(), self._configChanged.wait()), return_when = asyncio.FIRST_COMPLETED)
await asyncio.wait({asyncio.create_task(stopEvent.wait()), asyncio.create_task(self._configChanged.wait())}, return_when = asyncio.FIRST_COMPLETED)
await runner.cleanup()
if stopEvent.is_set():
break


Loading…
Cancel
Save