Browse Source

support python 3.6+ by changing to ensure_future.

hosting v0.0.2-rc1
Michael Pilosov 2 years ago
parent
commit
8e8d5cd36a
  1. 12
      src/announce_server/server.py

12
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)

Loading…
Cancel
Save