Mark async socket handling task done and implement startup cleanup
This commit is contained in:
@@ -7,6 +7,7 @@ in ``app.main`` delegates resource creation and task registration here.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import suppress
|
||||
from pathlib import Path
|
||||
|
||||
import aiohttp
|
||||
@@ -101,13 +102,22 @@ async def startup_shared_resources(
|
||||
http_session: aiohttp.ClientSession = _create_http_session(settings)
|
||||
geo_service.init_geoip(settings.geoip_db_path)
|
||||
|
||||
scheduler: AsyncIOScheduler = AsyncIOScheduler(timezone="UTC")
|
||||
scheduler.start()
|
||||
scheduler: AsyncIOScheduler | None = None
|
||||
try:
|
||||
scheduler = AsyncIOScheduler(timezone="UTC")
|
||||
scheduler.start()
|
||||
|
||||
health_check.register(app)
|
||||
blocklist_import.register(app)
|
||||
geo_cache_flush.register(app)
|
||||
geo_re_resolve.register(app)
|
||||
history_sync.register(app)
|
||||
health_check.register(app)
|
||||
blocklist_import.register(app)
|
||||
geo_cache_flush.register(app)
|
||||
geo_re_resolve.register(app)
|
||||
history_sync.register(app)
|
||||
|
||||
return http_session, scheduler
|
||||
return http_session, scheduler
|
||||
except Exception:
|
||||
with suppress(Exception):
|
||||
await http_session.close()
|
||||
if scheduler is not None:
|
||||
with suppress(Exception):
|
||||
scheduler.shutdown(wait=False)
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user