Skip to content

Commit 4e23351

Browse files
committed
Small changes
1 parent 90e7aab commit 4e23351

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

launcher.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import glob
44
import math
55
from http.client import HTTPException
6+
from signal import signal, SIGINT, SIGTERM
67

78
import discord
89
import numpy as np
@@ -73,10 +74,13 @@ async def on_command_error(ctx: Interaction, exc) -> None:
7374
else:
7475
raise exc
7576

76-
async def exit_handler():
77-
asyncio.run(bot.db.commit())
78-
79-
atexit.register(asyncio.run, (exit_handler,))
77+
def close():
78+
bot.loop.run_until_complete(bot.close())
79+
bot.loop.stop()
80+
bot.loop.close()
81+
exit()
82+
atexit.register(close)
83+
# signal(SIGINT, close)
8084
await bot.db.build()
8185
await bot.start(bot.config.token)
8286

lib/bot/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async def on_connect(self):
6767
await self.register_guilds()
6868
asyncio.ensure_future(self.monitor_shutdown())
6969
print(f"Signed into {self.user.display_name}#{self.user.discriminator}")
70-
asyncio.ensure_future(self.timer.start())
70+
# asyncio.ensure_future(self.timer.start())
7171

7272
async def on_shard_ready(self, shard_id):
7373
await self.change_presence(activity=discord.Activity(type=discord.ActivityType.watching,

lib/db/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,5 @@ async def close(self) -> None:
263263
await self.cxn.close()
264264

265265
async def run(self, command, *values) -> None:
266-
await self.cur.execute(command, tuple(values))
266+
await self.cur.execute(command, tuple(values))
267+
await self.commit()

lib/progress/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ def __init__(self, msg: str, total: int):
4646
self.total = total
4747

4848
def start(self):
49-
sys.stdout.write(f"\r{self.msg} {self.iteration/self.total*100:.2f}%")
49+
sys.stdout.write(f"\r{self.msg} [{self.iteration}/{self.total}]")
5050
sys.stdout.flush()
5151

5252
def next(self):
5353
if not self.total:
5454
print(self.msg)
5555
self.iteration += 1
5656
if self.iteration > self.total: raise ValueError("Can't iterate more then the total")
57-
sys.stdout.write(f"\r{self.msg} {self.iteration/self.total*100:.2f}%")
57+
sys.stdout.write(f"\r{self.msg} [{self.iteration}/{self.total}]")
5858
sys.stdout.flush()
5959
if self.iteration == self.total:
6060
print("")

0 commit comments

Comments
 (0)