refactor: cleaned main file
This commit is contained in:
16
core/lifespan.py
Normal file
16
core/lifespan.py
Normal file
@ -0,0 +1,16 @@
|
||||
import contextlib
|
||||
|
||||
from fastapi.applications import AppType
|
||||
|
||||
from task_management import broker
|
||||
|
||||
|
||||
@contextlib.asynccontextmanager
|
||||
async def lifespan(app: AppType):
|
||||
if not broker.is_worker_process:
|
||||
await broker.startup()
|
||||
|
||||
yield
|
||||
|
||||
if not broker.is_worker_process:
|
||||
await broker.shutdown()
|
||||
Reference in New Issue
Block a user