Commit 4ff741a1 authored by davebshow's avatar davebshow
Browse files

profiling

parent 04a76593
......@@ -3,4 +3,4 @@ from .connection import (WebsocketPool, AiohttpFactory, BaseFactory,
BaseConnection)
from .client import GremlinClient, create_client
from .exceptions import RequestError, GremlinServerError, SocketClientError
__version__ = "0.0.3"
__version__ = "0.0.3dev"
......@@ -155,18 +155,20 @@ 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.streams.EofStream:
except aiohttp.EofStream:
self._conn.feed_pool()
except Exception:
self._conn.feed_pool()
raise
else:
message.cancel()
......
......@@ -230,9 +230,17 @@ class AiohttpConnection(BaseConnection):
yield from self.release()
raise
if message.tp == aiohttp.MsgType.binary:
self.parser.feed_data(message.data.decode())
try:
self.parser.feed_data(message.data.decode())
except Exception:
self.release()
raise
elif message.tp == aiohttp.MsgType.text:
self.parser.feed_data(message.data.strip())
try:
self.parser.feed_data(message.data.strip())
except Exception:
self.release()
raise
else:
try:
if message.tp == aiohttp.MsgType.close:
......
......@@ -23,15 +23,13 @@ def gremlin_response_parser(out, buf):
if message.status_code == 200:
out.feed_data(message)
elif message.status_code == 299:
out.feed_data(message)
out.feed_eof()
else:
try:
if message.status_code < 500:
raise RequestError(message.status_code, message.message)
else:
raise GremlinServerError(message.status_code, message.message)
finally:
yield from connection.release()
if message.status_code < 500:
raise RequestError(message.status_code, message.message)
else:
raise GremlinServerError(message.status_code, message.message)
class GremlinWriter:
......
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