diff --git a/src/dispatch/flask.py b/src/dispatch/flask.py index 2498682..8cece0e 100644 --- a/src/dispatch/flask.py +++ b/src/dispatch/flask.py @@ -20,6 +20,7 @@ def read_root(): import asyncio import logging import threading + # from queue import Queue from typing import Optional, Union diff --git a/src/dispatch/test/__init__.py b/src/dispatch/test/__init__.py index aa5eec5..7669f5e 100644 --- a/src/dispatch/test/__init__.py +++ b/src/dispatch/test/__init__.py @@ -4,7 +4,7 @@ import unittest from datetime import datetime, timedelta from functools import wraps -from typing import Any, Callable, Coroutine, Optional, TypeVar, overload +from typing import Any, Callable, Coroutine, Dict, Optional, TypeVar, overload import aiohttp from aiohttp import web @@ -83,7 +83,7 @@ def url(self): class Service(web.Application): - tasks: dict[str, asyncio.Task[CallResult]] + tasks: Dict[str, asyncio.Task[CallResult]] _session: Optional[aiohttp.ClientSession] = None def __init__(self, session: Optional[aiohttp.ClientSession] = None): @@ -279,6 +279,7 @@ async def main(reg: R, fn: Callable[[R], Coroutine[Any, Any, None]]) -> None: def run(reg: R, fn: Callable[[R], Coroutine[Any, Any, None]]) -> None: return asyncio.run(main(reg, fn)) + # TODO: these decorators still need work, until we figure out serialization # for cell objects, they are not very useful since the registry they receive # as argument cannot be used to register dispatch functions. @@ -295,6 +296,7 @@ def run(reg: R, fn: Callable[[R], Coroutine[Any, Any, None]]) -> None: # # (WIP) + def function(fn: Callable[[Registry], Coroutine[Any, Any, None]]) -> Callable[[], None]: @wraps(fn) def wrapper(): @@ -322,6 +324,7 @@ def aiotest( This decorator is internal only, it shouldn't be exposed in the public API of this module. """ + @wraps(fn) def test(self): self.server_loop.run_until_complete(fn(self))