Commit 9a1912f6 authored by davebshow's avatar davebshow
Browse files

getting ready for release

parent 1466f0f7
# aiogremlin 0.0.4 [(gizmo grew up)](https://pypi.python.org/pypi/gizmo/0.1.12)
# aiogremlin 0.0.5 [(gizmo grew up)](https://pypi.python.org/pypi/gizmo/0.1.12)
`aiogremlin` is a **Python 3** driver for the the [Tinkerpop 3 Gremlin Server](http://www.tinkerpop.com/docs/3.0.0.M7/#gremlin-server). This module is built on [Asyncio](https://docs.python.org/3/library/asyncio.html). By default it uses the [aiohttp](http://aiohttp.readthedocs.org/en/v0.15.3/index.html) websocket client , but it is easy to plug in a different implementation. `aiogremlin` is currently in **alpha** mode, but all major functionality has test coverage.
......
from .abc import AbstractFactory, AbstractConnection
from .connection import (WebsocketPool, AiohttpFactory, BaseFactory,
BaseConnection)
from .client import GremlinClient, create_client
from .client import (create_client, GremlinClient, GremlinResponse,
GremlinResponseStream)
from .exceptions import RequestError, GremlinServerError, SocketClientError
__version__ = "0.0.4dev"
from .protocol import GremlinWriter
__version__ = "0.0.5"
......@@ -109,9 +109,7 @@ class GremlinClient:
connection = yield from self.pool.connect(self.uri, loop=self.loop)
writer = GremlinWriter(connection)
connection = yield from writer.write(message, binary=binary)
queue = connection.parser.set_parser(gremlin_response_parser,
output=aiohttp.DataQueue(loop=self._loop))
return GremlinResponse(connection, queue, loop=self._loop)
return GremlinResponse(connection, loop=self._loop)
@asyncio.coroutine
def execute(self, gremlin, bindings=None, lang=None,
......@@ -128,9 +126,9 @@ class GremlinClient:
class GremlinResponse:
def __init__(self, conn, queue, loop=None):
def __init__(self, conn, loop=None):
self._loop = loop or asyncio.get_event_loop()
self._stream = GremlinResponseStream(conn, queue, loop=self._loop)
self._stream = GremlinResponseStream(conn, loop=self._loop)
@property
def stream(self):
......@@ -155,23 +153,25 @@ class GremlinResponse:
class GremlinResponseStream:
def __init__(self, conn, queue, loop=None):
def __init__(self, conn, loop=None):
self._conn = conn
self._queue = queue
self._loop = loop or asyncio.get_event_loop()
data_stream = aiohttp.DataQueue(loop=self._loop)
self._stream = self._conn.parser.set_parser(gremlin_response_parser,
output=data_stream)
@asyncio.coroutine
def read(self):
# For 3.0.0.M9
# if self._queue.at_eof():
# if self._stream.at_eof():
# self._conn.feed_pool()
# message = None
# else:
# This will be different 3.0.0.M9
yield from self._conn._receive()
if self._queue.is_eof():
if self._stream.is_eof():
self._conn.feed_pool()
message = None
else:
message = yield from self._queue.read()
message = yield from self._stream.read()
return message
import asyncio
import collections
from aiogremlin import GremlinClient
@asyncio.coroutine
def attack(loop):
client = GremlinClient(loop=loop, poolsize=1000)
execute = client.execute
out_times = collections.deque()
processed_count = 0
@asyncio.coroutine
def do_bomb():
nonlocal processed_count
try:
t1 = loop.time()
resp = yield from execute("1 + 1")
assert resp[0].status_code == 200, resp[0].status_code
t2 = loop.time()
out_times.append(t2 - t1)
processed_count += 1
except Exception:
print("an exception occurred {}".format(resp[0].status_code))
bombers = []
for i in range(10000):
bomber = asyncio.async(do_bomb())
bombers.append(bomber)
t1 = loop.time()
yield from asyncio.gather(*bombers, loop=loop)
t2 = loop.time()
rps = processed_count / (t2 - t1)
print("Benchmark complete: {} rps".format(rps))
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(attack(loop))
......@@ -2,3 +2,4 @@
0.0.2 - 5/1/2015: Added an init_pool method and a create_client constructor.
0.0.3 - 5/2/2015: Using ujson for serialization.
0.0.4 - 5/12/2015: Added support for sessions.
0.0.5 - 5/13/2015: Using EofStream terminator technique to prepare for 3.0.0.M9
......@@ -3,7 +3,7 @@ from setuptools import setup
setup(
name="aiogremlin",
version="0.0.4",
version="0.0.5",
url="",
license="MIT",
author="davebshow",
......
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