Skip to content

Commit

Permalink
fix compatibility with Python 3.8
Browse files Browse the repository at this point in the history
Signed-off-by: Achille Roussel <[email protected]>
  • Loading branch information
achille-roussel committed Jun 12, 2024
1 parent 8a47832 commit db64dee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/dispatch/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def read_root():
import asyncio
import logging
import threading

# from queue import Queue
from typing import Optional, Union

Expand Down
7 changes: 5 additions & 2 deletions src/dispatch/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand All @@ -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():
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit db64dee

Please sign in to comment.