Skip to content

Commit

Permalink
🐛 fix lifespan sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu authored Mar 29, 2023
1 parent 5e02602 commit 3555e1e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions nonebot/drivers/_lifespan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Set, Union, Callable, Awaitable, cast
from typing import Any, List, Union, Callable, Awaitable, cast

from nonebot.utils import run_sync, is_coroutine_callable

Expand All @@ -9,20 +9,20 @@

class Lifespan:
def __init__(self) -> None:
self._startup_funcs: Set[LIFESPAN_FUNC] = set()
self._shutdown_funcs: Set[LIFESPAN_FUNC] = set()
self._startup_funcs: List[LIFESPAN_FUNC] = []
self._shutdown_funcs: List[LIFESPAN_FUNC] = []

def on_startup(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
self._startup_funcs.add(func)
self._startup_funcs.append(func)
return func

def on_shutdown(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
self._shutdown_funcs.add(func)
self._shutdown_funcs.append(func)
return func

@staticmethod
async def _run_lifespan_func(
funcs: Set[LIFESPAN_FUNC],
funcs: List[LIFESPAN_FUNC],
) -> None:
for func in funcs:
if is_coroutine_callable(func):
Expand Down

0 comments on commit 3555e1e

Please sign in to comment.