Skip to content

Commit

Permalink
minor (#30)
Browse files Browse the repository at this point in the history
* clean up

* release 0.0.209

---------

Co-authored-by: nggit <12218311+nggit@users.noreply.github.com>
  • Loading branch information
nggit and nggit committed Aug 8, 2024
1 parent d8853e5 commit 19695c4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='tremolo',
version='0.0.208',
version='0.0.209',
license='MIT',
author='nggit',
author_email='contact@anggit.com',
Expand Down
29 changes: 15 additions & 14 deletions tests/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion tremolo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.0.208'
__version__ = '0.0.209'

from .tremolo import Tremolo # noqa: E402
from . import exceptions # noqa: E402,F401
Expand Down
3 changes: 1 addition & 2 deletions tremolo/tremolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
)
Expand Down

0 comments on commit 19695c4

Please sign in to comment.