diff --git a/docs/source/conf.py b/docs/source/conf.py index b4770b9ff..900c617c3 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -303,6 +303,7 @@ autodoc_mock_imports = [ 'bluetooth_numbers', 'TheengsDecoder', 'simple_websocket', + 'uvicorn', ] sys.path.insert(0, os.path.abspath('../..')) diff --git a/platypush/backend/http/__init__.py b/platypush/backend/http/__init__.py index c57f5a02f..df9b0b331 100644 --- a/platypush/backend/http/__init__.py +++ b/platypush/backend/http/__init__.py @@ -252,8 +252,8 @@ class HttpBackend(Backend): kwargs = { 'bind': f'{self.bind_address}:{self.port}', 'workers': (cpu_count() * 2) + 1, - 'worker_class': 'eventlet', - 'timeout': 60, + 'worker_class_str': f'{__package__}.app.UvicornWorker', + 'timeout': 30, } WSGIApplicationWrapper(f'{__package__}.app:application', kwargs).run() diff --git a/platypush/backend/http/wsgi/__init__.py b/platypush/backend/http/wsgi/__init__.py index e304884ba..a2798e05d 100644 --- a/platypush/backend/http/wsgi/__init__.py +++ b/platypush/backend/http/wsgi/__init__.py @@ -1,4 +1,11 @@ +from typing import Any, Dict + from gunicorn.app.wsgiapp import WSGIApplication +from uvicorn.workers import UvicornWorker as BaseUvicornWorker + + +class UvicornWorker(BaseUvicornWorker): + CONFIG_KWARGS: Dict[str, Any] = {"loop": "auto", "http": "auto", "lifespan": "on"} class WSGIApplicationWrapper(WSGIApplication): diff --git a/requirements.txt b/requirements.txt index b1ead9c9d..16b74f211 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,6 @@ alembic bcrypt croniter -eventlet flask frozendict gunicorn @@ -22,6 +21,7 @@ rsa simple_websocket sqlalchemy tz +uvicorn websocket-client wsproto zeroconf>=0.27.0 diff --git a/setup.py b/setup.py index e83e61143..7f5712ac4 100755 --- a/setup.py +++ b/setup.py @@ -63,10 +63,9 @@ setup( 'alembic', 'bcrypt', 'croniter', - 'eventlet', 'flask', 'frozendict', - 'gunicorn @ https://github.com/benoitc/gunicorn/tarball/master', + 'gunicorn', 'marshmallow', 'marshmallow_dataclass', 'python-dateutil', @@ -78,6 +77,7 @@ setup( 'simple_websocket', 'sqlalchemy', 'tz', + 'uvicorn', 'websocket-client', 'wheel', 'wsproto',