formatting

This commit is contained in:
AF 2023-10-02 16:55:58 +00:00
parent cd03009eed
commit 89ac8a491b
2 changed files with 8 additions and 3 deletions

View File

@ -1,3 +1,5 @@
from __future__ import annotations
import asyncio import asyncio
import aiohttp import aiohttp
@ -54,7 +56,7 @@ class AppContext:
task = asyncio.create_task(start_app(app)) task = asyncio.create_task(start_app(app))
return app, task return app, task
async def __aenter__(self) -> "AppContext": async def __aenter__(self) -> AppContext:
self.__task: asyncio.Task[tuple[web.Application, asyncio.Task[None]] | None] = asyncio.create_task(self.start()) self.__task: asyncio.Task[tuple[web.Application, asyncio.Task[None]] | None] = asyncio.create_task(self.start())
return self return self

View File

@ -1,7 +1,9 @@
from __future__ import annotations
import asyncio import asyncio
import traceback import traceback
from contextlib import AsyncExitStack from contextlib import AsyncExitStack
from typing import AsyncIterable, Callable, TypeVar from typing import AsyncIterable, TypeVar
import discord import discord
@ -106,7 +108,7 @@ class MainService:
async def create(self, guild: discord.Guild) -> MainAudio: async def create(self, guild: discord.Guild) -> MainAudio:
return await MainAudio.create(self.__servicing, self.__volumes, self.__queues, guild) return await MainAudio.create(self.__servicing, self.__volumes, self.__queues, guild)
async def __aenter__(self) -> "MainService": async def __aenter__(self) -> MainService:
async with AsyncExitStack() as es: async with AsyncExitStack() as es:
self.__locks = Locks() self.__locks = Locks()
self.__volumes = await es.enter_async_context(DbFactory(myroot / "volume.db", kvfactory=KVJson())) self.__volumes = await es.enter_async_context(DbFactory(myroot / "volume.db", kvfactory=KVJson()))
@ -120,6 +122,7 @@ class MainService:
self.register_instrumentation() self.register_instrumentation()
self.__es = es.pop_all() self.__es = es.pop_all()
return self return self
raise RuntimeError
async def __aexit__(self, exc_type, exc_val, exc_tb): async def __aexit__(self, exc_type, exc_val, exc_tb):
async with self.__es: async with self.__es: