From 3d69787d0614de72b3f057324b96f5e9162b1b1b Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Sun, 25 Dec 2016 09:55:07 -0800 Subject: [PATCH] Get rid of flaky list, dict check --- sanic/server.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sanic/server.py b/sanic/server.py index b5e27f5a..d33f968b 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -164,12 +164,9 @@ class HttpProtocol(asyncio.Protocol): # as fast as ever attempt_write(response) except AttributeError: - try: - # A performant way to check if we have a list or dict - # Both list and dict contain a `clear` function - response.clear + if isinstance(response, (list, dict)): attempt_write(json(response)) - except AttributeError: + else: attempt_write(text(str(response))) if not keep_alive: