diff --git a/README.md b/README.md index 5888c87aa96b8b53d8127b5730e3508f84fec834..fdda119314229117156b1ddea8fb330e6ba21207 100644 --- a/README.md +++ b/README.md @@ -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. -```