Compare commits

..

3 Commits

Author SHA1 Message Date
Michael Pilosov
91b40234cb python 3.7+ 2023-03-19 20:03:22 -06:00
Michael Pilosov
91621847e5 readme update 2023-03-19 19:46:21 -06:00
Michael Pilosov
8e8d5cd36a support python 3.6+ by changing to ensure_future. 2023-03-19 19:33:52 -06:00
5 changed files with 18 additions and 8 deletions

View File

@ -10,4 +10,7 @@ pub: build
install:
pip install -e .[dev,pub]
.PHONY: build clean pub install
test-api:
docker run --rm -ti -p 4999:4999 python:3.7-slim bash -c "pip install announce_server==0.0.2rc2; pip install 'python-socketsio[asyncio_client]==5.0'; announce_server start_registry"
.PHONY: build clean pub install test-api

View File

@ -73,8 +73,8 @@ To start the registry server with the default configuration, run:
announce_server start_registry
```
To start the registry server with a custom IP address, port number, heartbeat interval, and timeout, run:
The full syntax is equivalent to:
```bash
announce_server start_registry --address localhost --port 4998 --heartbeat_interval 10 --heartbeat_timeout 5
announce_server start_registry --address 0.0.0.0 --port 4999 --heartbeat_interval 5 --heartbeat_timeout 3
```

View File

@ -12,7 +12,6 @@ classifiers =
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
@ -24,7 +23,7 @@ package_dir =
= src
packages = find:
install_requires =
python-socketio[asyncio_client]
python-socketio[asyncio_client]~=5.0.0
[options.packages.find]
where = src

View File

@ -7,5 +7,5 @@ setup(
"setuptools_scm",
],
use_scm_version=True,
python_requires=">=3.6",
python_requires=">=3.7", # because of python-socketsio[asyncio_client]
)

View File

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