diff --git a/src/announce_server/server.py b/src/announce_server/server.py index 8d6ba35..da0ddbe 100644 --- a/src/announce_server/server.py +++ b/src/announce_server/server.py @@ -137,10 +137,18 @@ def start_server(address, port, heartbeat_interval, heartbeat_timeout): The timeout for waiting for a response in seconds. """ loop = asyncio.get_event_loop() - heartbeat_task = loop.create_task( + # Python 3.7+, coroutines only: + # heartbeat_task = loop.create_task( + # heartbeat(sio, heartbeat_interval, heartbeat_timeout) + # ) + # aiohttp_app = loop.create_task(web._run_app(app, host=address, port=port)) + + # Python 3.6+ compatible. Supports any awaitable: + heartbeat_task = asyncio.ensure_future( heartbeat(sio, heartbeat_interval, heartbeat_timeout) ) - aiohttp_app = loop.create_task(web._run_app(app, host=address, port=port)) + + aiohttp_app = asyncio.ensure_future(web._run_app(app, host=address, port=port)) exit_handler = create_exit_handler(loop, heartbeat_task) signal.signal(signal.SIGINT, exit_handler)