Skip to content

Commit

Permalink
Fix for py3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
dorinclisu committed Oct 4, 2024
1 parent 1648495 commit 68b2c5b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import logging

from anyio import sleep
from litestar import Litestar, get, put

from runner_with_api import AsyncRunnerWithAPI


Expand All @@ -42,7 +41,7 @@ class MyRunner(AsyncRunnerWithAPI):

@put('/config')
async def configure(self, data: dict) -> None:
logging.info('Configuring process ...')
logging.info('Configuring process')
self.config = data

@get('/config')
Expand Down
4 changes: 2 additions & 2 deletions runner_with_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import signal
import types
from contextlib import asynccontextmanager
from typing import Any
from typing import Any, Union

import uvicorn
from anyio import create_task_group
Expand Down Expand Up @@ -69,7 +69,7 @@ async def _lifespan(app: ASGIApplication):
return _lifespan


def run_with_api(self, app: ASGIApplication | Any, host='127.0.0.1', port=8000):
def run_with_api(self, app: Union[ASGIApplication, Any], host='127.0.0.1', port=8000):
"""Run the API listener on host:port while the runner lifespan is managed.
Unix signal handlers are installed by uvicorn for graceful shutdown.
"""
Expand Down
3 changes: 1 addition & 2 deletions tests/test_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ async def run(self) -> None:

@router.put('/config')
async def configure(self, config: dict) -> None:
logging.info('Configuring process ...')
await sleep(1)
logging.info('Configuring process')
self.config = config.copy()


Expand Down
3 changes: 1 addition & 2 deletions tests/test_litestar.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ async def run(self) -> None:

@put('/config')
async def configure(self, data: dict) -> None:
logging.info('Configuring process ...')
await sleep(1)
logging.info('Configuring process')
self.config = data


Expand Down

0 comments on commit 68b2c5b

Please sign in to comment.