From 666d3c26bd61cb4ba78b64c8d7f0cb5d2a021029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liisa=20R=C3=A4tsep?= Date: Thu, 30 Jun 2022 15:19:52 +0300 Subject: [PATCH] fix mq timeout units --- README.md | 4 ++-- app/cleanup.py | 2 ++ app/config.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ff4065e..993eaf6 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Environment variables: - `MQ_PASSWORD` - RabbitMQ user password - `MQ_HOST` - RabbitMQ host - `MQ_PORT` (optional) - RabbitMQ port (`5672` by default) - - `MQ_TIMEOUT` (optional) - Message timeout in milliseconds (`1200000` by default) + - `MQ_TIMEOUT` (optional) - Message timeout in seconds (`1200` by default) - `MQ_EXCHANGE` (optional) - RabbitMQ exchange name (`speech-to-text` by default) - Configuration to connect to a MySQL database: - `MYSQL_HOST` - MySQL hostname @@ -34,7 +34,7 @@ Environment variables: return transcriptions) - `API_PASSWORD` - password that the ASR worker component will use to authenticate itself - Cleanup configuration for files and database records: - - `API_CLEANUP_INTERVAL` (optional) - how often cleanup is initiated (in seconds, `600` by default) + - `API_CLEANUP_INTERVAL` (optional) - how often cleanup is initiated (in seconds, `60` by default) - `API_EXPIRATION_THRESHOLD` (optional) - number of seconds after which the job is marked as cancelled (if the job was still in progress) or expired (if the job was done) in the database and its files are deleted (`1200` by default) diff --git a/app/cleanup.py b/app/cleanup.py index b21b361..cb9492b 100644 --- a/app/cleanup.py +++ b/app/cleanup.py @@ -23,6 +23,8 @@ async def _run(): await aiofiles.os.remove(os.path.join(api_settings.storage_path, f"{job_id}.txt")) await aiofiles.os.remove(os.path.join(api_settings.storage_path, f"{job_id}.wav")) + LOGGER.info("Cleanup finished.") + class Cleanup: _running = False diff --git a/app/config.py b/app/config.py index 1e11d61..74d86b6 100644 --- a/app/config.py +++ b/app/config.py @@ -5,7 +5,7 @@ class APISettings(BaseSettings): version: str username: str = 'user' password: str = 'pass' - cleanup_interval: int = 600 # 10 minutes - run db & file cleanup + cleanup_interval: int = 60 # 1 minute - run db & file cleanup expiration_threshold: int = 1200 # 20 minutes - expire / cancel jobs without updates removal_threshold: int = 86400 # 24 h - remove db records after expiration / cancellation @@ -21,7 +21,7 @@ class MQSettings(BaseSettings): username: str = 'guest' password: str = 'guest' exchange: str = 'speech-to-text' - timeout: int = 1200000 # 120 minutes + timeout: int = 1200 # 20 minutes class Config: env_prefix = 'mq_'