Commit 17b44331 authored by davebshow's avatar davebshow
Browse files

updating README

parent 40fc8e29
......@@ -35,11 +35,6 @@ Note that the GremlinClient constructor and the create_client function take [key
```python
>>> loop = asyncio.get_event_loop()
>>> gc = GremlinClient(url='ws://localhost:8182/', loop=loop) # Default url
# Or even better, use the constructor function. This will init pool connections.
# ***Must be done inside a coroutine***
>>> gc = yield from create_client(loop=loop)
# Or outside of a coroutine using the loop to help
>>> gc = loop.run_until_complete(create_client(loop=loop))
# Use get.
>>> @asyncio.coroutine
......@@ -87,22 +82,3 @@ For convenience, `aiogremlin` also provides a method `execute`, which is equival
>>> loop.run_until_complete(gc.close()) # Explicitly close client!!!
>>> loop.close()
```
To avoid the explicit client close, `aiogremlin` provides a class called `ConnectionContextManager`. To create an instance of `ConnectionContextManager`, get a connection from a `WebSocketPool` instance as follows:
```python
>>> loop = asyncio.get_event_loop()
# Note that url is a required positional param here!
# Pool does not open any connections until requested.
>>> pool = aiogremlin.WebSocketPool('ws://localhost:8182/')
>>> @asyncio.coroutine
... def go(pool, loop):
... with (yield from pool) as conn:
... gc = aiogremlin.GremlinClient(connection=conn, loop=loop)
... resp = yield from gc.execute("1 + 1")
... return resp
>>> result = loop.run_until_complete(go(pool, loop))
>>> result
[Message(status_code=200, data=[2], message={}, metadata='')]
>>> loop.close() # Close loop, but client connections will be closed.
```
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