davebshow / gremlinclient Goto Github PK
View Code? Open in Web Editor NEWA Python client for TP3 Gremlin Server for Tornado, Trollius, or Asyncio
License: MIT License
A Python client for TP3 Gremlin Server for Tornado, Trollius, or Asyncio
License: MIT License
Stream.read
sometimes throws an InvalidStateError
originating at connection.py:344. It seems that sometimes the future is already cancelled at that point, so future.set_result(message)
raises InvalidStateError
.
I haven't found a cause yet.
Hey @davebshow first off, thanks for this client it's been really helpful in getting up and going with TP3/Titan1.0
We were having some issues handling the RuntimeError raised as part of GremlinResponse#parser. It might be we're going about it incorrectly, which I'm still looking into. However, in the meantime I made an update that will allow you to pass a flag for if you want gremlinclient to not raise the exception, and return the errors/status code in the Message tuple.
Also, it looked like there was a positioning mismatch of message and metadata on the response, so we weren't actually getting the error text from the server. So we swapped that as well. I didn't know if you preferred an issue before a pull request, but I'll open one as well.
Thoughts/Ideas/Issues?
@platinummonkey - Which server response API do you prefer for the new client?
aiogremlin uses the following API to get a list of messages:
resp = yield from gc.submit("x + x", bindings={"x": 4})
result = yield from resp.get()
But for streaming responses, you do this:
resp = yield from gc.submit("x + x", bindings={"x": 1})
while True:
result = yield from resp.stream.read()
if result is None: break
For the new client, I was thinking about maintaining the response.get
method while simplifying the streaming to something like this:
resp = yield from gc.submit("x + x", bindings={"x": 1})
while True:
result = yield from resp.read()
if result is None: break
Thoughts? Do you have a preference?
gremlinclient/gremlinclient/connection.py
Line 319 in 4456777
If the underlying WebSocket response message is already decoded, this call breaks.
Ideally, there should be a check to accommodate this.
Maybe assume already decoded if this line throws?
It took me a long time to realize to do this:
@gen.coroutine
def submit(gremlinServerURI, traversalString):
response = yield submit(gremlinServerURI, traversalString)
while True:
result = yield response.read()
if result is None:
break
raise gen.Return(result.data)
Where this is called via:
def toList(self):
return IOLoop.current().run_sync(lambda: Helper.submit(self.gremlinServerURI, self.traversalString))
For the following tutorial: http://tinkerpop.apache.org/docs/3.2.1-SNAPSHOT/tutorials/gremlin-language-variants/
Be nice to provide such "easy" methods in gremlinclient.
Do you know how to hook into an existing ioloop and retrieve results?
I've been playing around with adding futures via ioloop.add_future and many other, unsuccessful approaches. And you simply cannot run run_sync because it assumes it is the only loop running and throws an error. Any suggestions?
Thanks,
Mark
In gremlinclient.log
, the call to logging.basicConfig
makes calls to logging.basicConfig
a no-op in any client code that (directly or indirectly) imports this module.
From the docs for logging.basicConfig
:
This function does nothing if the root logger already has handlers configured for it.
Probably better not to force a logging configuration onto the client programmer's root logger!
The example script on the home page returns
tornado.httpclient.HTTPError: HTTP 400: Bad Request
With the following on the server:
titan_1 | 185142 [gremlin-server-worker-1] WARN org.apache.tinkerpop.gremlin.server.handler.HttpGremlinEndpointHandler - Invalid request - responding with 400 Bad Request and no gremlin script supplied
Against Titan (https://github.com/elubow/titan-gremlin/blob/master/Dockerfile)
Which depends on TinkerPop 3.0.1-incubating
Is this server supported?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.