Commit 30e60c05 authored by davebshow's avatar davebshow
Browse files

fixed performance draining code: simplify!

parent 02eddb58
......@@ -162,22 +162,14 @@ class GremlinResponseStream:
@asyncio.coroutine
def _read(self):
# This will find the eof set at 200 response
if self._queue.at_eof():
self._conn.feed_pool()
return
message = asyncio.async(self._queue.read(), loop=self._loop)
done, pending = yield from asyncio.wait(
[message, asyncio.async(self._conn._receive(), loop=self._loop)],
loop=self._loop, return_when=asyncio.FIRST_COMPLETED)
if message in done:
# Temporary
try:
return message.result()
except aiohttp.EofStream:
self._conn.feed_pool()
message = None
else:
message.cancel()
yield from self._conn._receive()
message = yield from self._queue.read()
return message
@asyncio.coroutine
def read(self):
......
......@@ -22,9 +22,15 @@ def gremlin_response_parser(out, buf):
message["status"]["message"])
if message.status_code == 200:
out.feed_data(message)
# out.feed_eof()
elif message.status_code == 299:
out.feed_data(message)
out.feed_eof()
# elif message.status_code == 206:
# out.feed_data(message)
# elif message.status_code == 204:
# out.feed_data(message)
# out.feed_eof()
else:
if message.status_code < 500:
raise RequestError(message.status_code, message.message)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment