From 19695c4d8ccf559bb40f8f140969fed6f8751dbc Mon Sep 17 00:00:00 2001 From: nggit Date: Sun, 12 Nov 2023 09:47:52 +0700 Subject: [PATCH] minor (#30) * clean up * release 0.0.209 --------- Co-authored-by: nggit <12218311+nggit@users.noreply.github.com> --- setup.py | 2 +- tests/http_server.py | 29 +++++++++++++++-------------- tremolo/__init__.py | 2 +- tremolo/tremolo.py | 3 +-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/setup.py b/setup.py index 9522898..fc3245c 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name='tremolo', - version='0.0.208', + version='0.0.209', license='MIT', author='nggit', author_email='contact@anggit.com', diff --git a/tests/http_server.py b/tests/http_server.py index aad9ca3..c4cf4c8 100644 --- a/tests/http_server.py +++ b/tests/http_server.py @@ -23,30 +23,30 @@ @app.on_worker_start -async def worker_start(**server): - worker = server['context'] - worker.shared = 0 - worker.socket_family = 'AF_UNIX' +async def worker_start(**worker): + worker_ctx = worker['context'] + worker_ctx.shared = 0 + worker_ctx.socket_family = 'AF_UNIX' @app.on_worker_start() -async def worker_start2(**server): +async def worker_start2(**worker): pass @app.on_worker_stop() -async def worker_stop2(**server): +async def worker_stop2(**worker): pass @app.on_worker_stop -async def worker_stop(**server): - worker = server['context'] +async def worker_stop(**worker): + worker_ctx = worker['context'] - if worker.socket_family == 'AF_UNIX': - assert worker.shared == 0 + if worker_ctx.socket_family == 'AF_UNIX': + assert worker_ctx.shared == 0 else: - assert worker.shared > 0 + assert worker_ctx.shared > 0 @app.on_connect @@ -64,11 +64,12 @@ async def on_close(**server): @app.on_request -async def my_request_middleware(worker=None, **server): +async def my_request_middleware(**server): request = server['request'] response = server['response'] - worker.shared += 1 - worker.socket_family = request.socket.family.name + worker_ctx = server['worker'] + worker_ctx.shared += 1 + worker_ctx.socket_family = request.socket.family.name assert request.ctx.foo == 'bar' diff --git a/tremolo/__init__.py b/tremolo/__init__.py index 85e4a77..9cb8eaa 100644 --- a/tremolo/__init__.py +++ b/tremolo/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.0.208' +__version__ = '0.0.209' from .tremolo import Tremolo # noqa: E402 from . import exceptions # noqa: E402,F401 diff --git a/tremolo/tremolo.py b/tremolo/tremolo.py index fabb99a..8e7c6d2 100644 --- a/tremolo/tremolo.py +++ b/tremolo/tremolo.py @@ -630,10 +630,9 @@ def run(self, host=None, port=0, reuse_port=True, worker_num=1, **kwargs): options = {**kwargs, **options} print( - ' run(host=%s, port=%d, reuse_port=%s, worker_num=%d, %s)' % ( + ' run(host=%s, port=%d, worker_num=%d, %s)' % ( _host, _port, - reuse_port, worker_num, ', '.join('%s=%s' % item for item in options.items())) )