Get rid of flaky list, dict check

This commit is contained in:
Eli Uriegas 2016-12-25 09:55:07 -08:00
parent d3e99c9a35
commit 3d69787d06

View File

@ -164,12 +164,9 @@ class HttpProtocol(asyncio.Protocol):
# as fast as ever # as fast as ever
attempt_write(response) attempt_write(response)
except AttributeError: except AttributeError:
try: if isinstance(response, (list, dict)):
# A performant way to check if we have a list or dict
# Both list and dict contain a `clear` function
response.clear
attempt_write(json(response)) attempt_write(json(response))
except AttributeError: else:
attempt_write(text(str(response))) attempt_write(text(str(response)))
if not keep_alive: if not keep_alive: