1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

Проверка 09.02.2025

This commit is contained in:
MoonTestUse1
2025-02-09 01:11:49 +06:00
parent ce52f8a23a
commit 0aa3ef8fc2
5827 changed files with 14316 additions and 1906434 deletions

View File

@@ -1,4 +1,6 @@
from typing import Any, Dict
from __future__ import annotations
from typing import Any
from uvicorn import Config
@@ -6,7 +8,7 @@ from uvicorn import Config
class LifespanOff:
def __init__(self, config: Config) -> None:
self.should_exit = False
self.state: Dict[str, Any] = {}
self.state: dict[str, Any] = {}
async def startup(self) -> None:
pass

View File

@@ -1,7 +1,9 @@
from __future__ import annotations
import asyncio
import logging
from asyncio import Queue
from typing import Any, Dict, Union
from typing import Any, Union
from uvicorn import Config
from uvicorn._types import (
@@ -35,12 +37,12 @@ class LifespanOn:
self.logger = logging.getLogger("uvicorn.error")
self.startup_event = asyncio.Event()
self.shutdown_event = asyncio.Event()
self.receive_queue: "Queue[LifespanReceiveMessage]" = asyncio.Queue()
self.receive_queue: Queue[LifespanReceiveMessage] = asyncio.Queue()
self.error_occured = False
self.startup_failed = False
self.shutdown_failed = False
self.should_exit = False
self.state: Dict[str, Any] = {}
self.state: dict[str, Any] = {}
async def startup(self) -> None:
self.logger.info("Waiting for application startup.")
@@ -67,9 +69,7 @@ class LifespanOn:
await self.receive_queue.put(shutdown_event)
await self.shutdown_event.wait()
if self.shutdown_failed or (
self.error_occured and self.config.lifespan == "on"
):
if self.shutdown_failed or (self.error_occured and self.config.lifespan == "on"):
self.logger.error("Application shutdown failed. Exiting.")
self.should_exit = True
else:
@@ -99,7 +99,7 @@ class LifespanOn:
self.startup_event.set()
self.shutdown_event.set()
async def send(self, message: "LifespanSendMessage") -> None:
async def send(self, message: LifespanSendMessage) -> None:
assert message["type"] in (
"lifespan.startup.complete",
"lifespan.startup.failed",
@@ -133,5 +133,5 @@ class LifespanOn:
if message.get("message"):
self.logger.error(message["message"])
async def receive(self) -> "LifespanReceiveMessage":
async def receive(self) -> LifespanReceiveMessage:
return await self.receive_queue.get()