Skip to content

Commit

Permalink
try fixing compat with 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 17, 2024
1 parent f0a54e2 commit 60c2312
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tests/test_fastapi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import socket
import sys
from typing import Any, Optional

import fastapi
Expand Down Expand Up @@ -56,7 +57,10 @@ def dispatch_test_init(self, reg: Registry) -> str:
self.sockets = [sock]
self.uvicorn = uvicorn.Server(config)
self.runner = Runner()
self.event = asyncio.Event()
if sys.version_info > (3, 8):
self.event = asyncio.Event()
else:
self.event = asyncio.Event(loop=self.runner.get_loop())
return f"http://{host}:{port}"

def dispatch_test_run(self):
Expand Down
7 changes: 6 additions & 1 deletion tests/test_http.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import socket
import sys
from http.server import HTTPServer

import dispatch.test
Expand Down Expand Up @@ -41,11 +42,15 @@ def dispatch_test_init(self, reg: Registry) -> str:
host = "127.0.0.1"
port = 0

self.aiowait = asyncio.Event()
self.aioloop = Runner()
self.aiohttp = Server(host, port, Dispatch(reg))
self.aioloop.run(self.aiohttp.start())

if sys.version_info > (3, 8):
self.aiowait = asyncio.Event()
else:
self.aiowait = asyncio.Event(loop=self.aioloop.get_loop())

return f"http://{self.aiohttp.host}:{self.aiohttp.port}"

def dispatch_test_run(self):
Expand Down

0 comments on commit 60c2312

Please sign in to comment.