diff --git a/relay/application.py b/relay/application.py index f59427e..cafef59 100644 --- a/relay/application.py +++ b/relay/application.py @@ -202,14 +202,10 @@ class CacheCleanupThread(Thread): def run(self) -> None: - cache = get_cache(self.app) - while self.running.is_set(): time.sleep(3600) logging.verbose("Removing old cache items") - cache.delete_old(14) - - cache.close() + self.app.cache.delete_old(14) def start(self) -> None: diff --git a/relay/manage.py b/relay/manage.py index 1cc24f4..3acd1c2 100644 --- a/relay/manage.py +++ b/relay/manage.py @@ -3,6 +3,7 @@ from __future__ import annotations import Crypto import asyncio import click +import os import platform import subprocess import sys @@ -238,9 +239,12 @@ def cli_run(ctx: click.Context, dev: bool = False) -> None: if getattr(sys, 'frozen', False): subprocess.run([sys.executable, 'run-gunicorn'], check = False) - return - ctx.obj.run(dev) + else: + ctx.obj.run(dev) + + # todo: figure out why the relay doesn't quit properly without this + os._exit(0) @cli.command('run-gunicorn') diff --git a/relay/views/api.py b/relay/views/api.py index e3c8bb8..be5999d 100644 --- a/relay/views/api.py +++ b/relay/views/api.py @@ -170,12 +170,6 @@ class Inbox(View): with self.database.session() as conn: for inbox in conn.execute('SELECT * FROM inboxes'): - try: - created = datetime.fromtimestamp(inbox['created'], tz = timezone.utc) - - except TypeError: - created = datetime.fromisoformat(inbox['created']) - inbox['created'] = created.isoformat() data.append(inbox) diff --git a/relay/views/frontend.py b/relay/views/frontend.py index a66efa5..fb6028f 100644 --- a/relay/views/frontend.py +++ b/relay/views/frontend.py @@ -46,7 +46,7 @@ class HomeView(View): async def get(self, request: Request) -> Response: with self.database.session() as conn: config = conn.get_config_all() - inboxes = conn.execute('SELECT * FROM inboxes').all() + inboxes = tuple(conn.execute('SELECT * FROM inboxes').all()) text = HOME_TEMPLATE.format( host = self.config.domain,