Back to uvicorn workers from eventlet.

The eventlet API has way too many dependency issues with gunicorn.

Still TODO: Fix or at least mitigate the WSGI workers timeout issue when
they handle websocket connections.
This commit is contained in:
Fabio Manganiello 2023-05-07 15:37:58 +02:00
parent 8102178ba4
commit 692180c653
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
5 changed files with 13 additions and 5 deletions

View File

@ -303,6 +303,7 @@ autodoc_mock_imports = [
'bluetooth_numbers', 'bluetooth_numbers',
'TheengsDecoder', 'TheengsDecoder',
'simple_websocket', 'simple_websocket',
'uvicorn',
] ]
sys.path.insert(0, os.path.abspath('../..')) sys.path.insert(0, os.path.abspath('../..'))

View File

@ -252,8 +252,8 @@ class HttpBackend(Backend):
kwargs = { kwargs = {
'bind': f'{self.bind_address}:{self.port}', 'bind': f'{self.bind_address}:{self.port}',
'workers': (cpu_count() * 2) + 1, 'workers': (cpu_count() * 2) + 1,
'worker_class': 'eventlet', 'worker_class_str': f'{__package__}.app.UvicornWorker',
'timeout': 60, 'timeout': 30,
} }
WSGIApplicationWrapper(f'{__package__}.app:application', kwargs).run() WSGIApplicationWrapper(f'{__package__}.app:application', kwargs).run()

View File

@ -1,4 +1,11 @@
from typing import Any, Dict
from gunicorn.app.wsgiapp import WSGIApplication 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): class WSGIApplicationWrapper(WSGIApplication):

View File

@ -5,7 +5,6 @@
alembic alembic
bcrypt bcrypt
croniter croniter
eventlet
flask flask
frozendict frozendict
gunicorn gunicorn
@ -22,6 +21,7 @@ rsa
simple_websocket simple_websocket
sqlalchemy sqlalchemy
tz tz
uvicorn
websocket-client websocket-client
wsproto wsproto
zeroconf>=0.27.0 zeroconf>=0.27.0

View File

@ -63,10 +63,9 @@ setup(
'alembic', 'alembic',
'bcrypt', 'bcrypt',
'croniter', 'croniter',
'eventlet',
'flask', 'flask',
'frozendict', 'frozendict',
'gunicorn @ https://github.com/benoitc/gunicorn/tarball/master', 'gunicorn',
'marshmallow', 'marshmallow',
'marshmallow_dataclass', 'marshmallow_dataclass',
'python-dateutil', 'python-dateutil',
@ -78,6 +77,7 @@ setup(
'simple_websocket', 'simple_websocket',
'sqlalchemy', 'sqlalchemy',
'tz', 'tz',
'uvicorn',
'websocket-client', 'websocket-client',
'wheel', 'wheel',
'wsproto', 'wsproto',