feat: python worker (bot, scraper, notifier, scheduler)

This commit is contained in:
opencode
2026-06-16 19:12:35 +02:00
committed by Lago
parent d32ce26d9e
commit fbbdc5e54b
7 changed files with 729 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import os
import logging
import asyncpg
logger = logging.getLogger(__name__)
_pool: asyncpg.Pool | None = None
async def get_pool() -> asyncpg.Pool:
global _pool
if _pool is None:
_pool = await asyncpg.create_pool(
host=os.getenv("POSTGRES_HOST", "db"),
port=int(os.getenv("POSTGRES_PORT", "5432")),
user=os.getenv("POSTGRES_USER", "postgres"),
password=os.getenv("POSTGRES_PASSWORD"),
database=os.getenv("POSTGRES_DB", "postgres"),
min_size=2,
max_size=10,
)
logger.info("Database pool initialized")
return _pool
async def close_pool() -> None:
global _pool
if _pool is not None:
await _pool.close()
logger.info("Database pool closed")
_pool = None