Skip to content

Commit dd28ba2

Browse files
committed
Fix async startup
1 parent 300b443 commit dd28ba2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

cloudbot/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from cloudbot.bot import CloudBot
1010
from cloudbot.util import async_util
1111

12+
1213
async def async_main():
1314
# store the original working directory, for use when restarting
1415
original_wd = Path().resolve()
@@ -55,7 +56,7 @@ def exit_gracefully(signum, frame):
5556
# start the bot
5657

5758
# CloudBot.run() will return True if it should restart, False otherwise
58-
restart = _bot.run()
59+
restart = await _bot.run()
5960

6061
# the bot has stopped, do we want to restart?
6162
if restart:

cloudbot/bot.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,21 @@ def data_dir(self) -> str:
186186
)
187187
return str(self.data_path)
188188

189-
def run(self):
189+
async def run(self):
190190
"""
191191
Starts CloudBot.
192192
This will load plugins, connect to IRC, and process input.
193193
:return: True if CloudBot should be restarted, False otherwise
194194
"""
195195
self.loop.set_default_executor(self.executor)
196196
# Initializes the bot, plugins and connections
197-
self.loop.run_until_complete(self._init_routine())
197+
await self._init_routine()
198198
# Wait till the bot stops. The stopped_future will be set to True to restart, False otherwise
199199
logger.debug("Init done")
200-
restart = self.loop.run_until_complete(self.stopped_future)
200+
restart = await self.stopped_future
201201
logger.debug("Waiting for plugin unload")
202-
self.loop.run_until_complete(self.plugin_manager.unload_all())
202+
await self.plugin_manager.unload_all()
203203
logger.debug("Unload complete")
204-
self.loop.close()
205204
return restart
206205

207206
def get_client(self, name: str) -> Type[Client]:

0 commit comments

Comments
 (0)