move event loop to globals.py

This commit is contained in:
j3d1 2023-11-27 20:23:21 +01:00
parent 101fa7b69d
commit 9e1d570b07
2 changed files with 2 additions and 3 deletions

View file

@ -2,7 +2,7 @@ import asyncio
import logging import logging
import signal import signal
loop = None loop = asyncio.get_event_loop()
def create_task(coro): def create_task(coro):
@ -24,7 +24,6 @@ async def shutdown(sig, loop):
def init_loop(): def init_loop():
global loop global loop
loop = asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGTERM, lambda: asyncio.create_task(shutdown(signal.SIGTERM, loop))) loop.add_signal_handler(signal.SIGTERM, lambda: asyncio.create_task(shutdown(signal.SIGTERM, loop)))
loop.add_signal_handler(signal.SIGINT, lambda: asyncio.create_task(shutdown(signal.SIGINT, loop))) loop.add_signal_handler(signal.SIGINT, lambda: asyncio.create_task(shutdown(signal.SIGINT, loop)))
return loop return loop

View file

@ -9,7 +9,7 @@ import uvicorn
django.setup() django.setup()
from helper import init_loop from core.globals import init_loop
from mail.protocol import LMTPHandler from mail.protocol import LMTPHandler
from mail.socket import UnixSocketLMTPController from mail.socket import UnixSocketLMTPController