From 9a08bdae4a6c9385f9292a06b2256893c7b82cb6 Mon Sep 17 00:00:00 2001 From: Alec Buckenheimer Date: Mon, 1 Oct 2018 09:46:18 -0400 Subject: [PATCH] fix flake8 linelength errors --- sanic/worker.py | 15 ++++++++++----- tests/test_routes.py | 15 ++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/sanic/worker.py b/sanic/worker.py index a5a39c82..05319d1f 100644 --- a/sanic/worker.py +++ b/sanic/worker.py @@ -147,18 +147,23 @@ if base is not None: self.notify() req_count = sum( - self.servers[srv]["requests_count"] for srv in self.servers + srv['requests_count'] for srv in self.servers.values() ) if self.max_requests and req_count > self.max_requests: self.alive = False - self.log.info("Max requests exceeded, shutting down: %s", - self) + self.log.info( + "Max requests exceeded, shutting down: %s", + self + ) elif pid == os.getpid() and self.ppid != os.getppid(): self.alive = False - self.log.info("Parent changed, shutting down: %s", self) + self.log.info( + "Parent changed, shutting down: %s", + self + ) else: await asyncio.sleep(1.0, loop=self.loop) - except (Exception, BaseException, GeneratorExit, KeyboardInterrupt): + except (BaseException, GeneratorExit, KeyboardInterrupt): pass @staticmethod diff --git a/tests/test_routes.py b/tests/test_routes.py index 68f4b0c7..d5f1c90a 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -173,33 +173,34 @@ def test_route_strict_slashes_set_to_false_and_host_is_a_list(app): # before fix, this raises a RouteExists error @app.get('/get', host=[site1, 'site2.com'], strict_slashes=False) - def handler(request): + def get_handler(request): return text('OK') request, response = app.test_client.get('http://' + site1 + '/get') assert response.text == 'OK' - @app.post('/post', host=[site1, 'site2.com'], strict_slashes=False) # noqa - def handler(request): + @app.post('/post', host=[site1, 'site2.com'], strict_slashes=False) + def post_handler(request): return text('OK') request, response = app.test_client.post('http://' + site1 + '/post') assert response.text == 'OK' - @app.put('/put', host=[site1, 'site2.com'], strict_slashes=False) # noqa - def handler(request): + @app.put('/put', host=[site1, 'site2.com'], strict_slashes=False) + def put_handler(request): return text('OK') request, response = app.test_client.put('http://' + site1 + '/put') assert response.text == 'OK' - @app.delete('/delete', host=[site1, 'site2.com'], strict_slashes=False) # noqa - def handler(request): + @app.delete('/delete', host=[site1, 'site2.com'], strict_slashes=False) + def delete_handler(request): return text('OK') request, response = app.test_client.delete('http://' + site1 + '/delete') assert response.text == 'OK' + def test_shorthand_routes_post(app): @app.post('/post')