Comments (2)
Ah didn't read your code very closely. I've been crazy busy the last couple
weeks. The problem with the way your submit is implemented is that it will
only return the first result. In the case of a streaming response, it won't
work. So, you either have to collect the streaming response in a list and
return after the while loop is broken, or you have to use the while loop in
your application code and process the results one at a time. Make sense?
On Thu, Apr 21, 2016 at 11:10 AM, Marko A. Rodriguez <
[email protected]> wrote:
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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#10
David M. Brown
R.A. CulturePlex Lab, Western University
from gremlinclient.
To elaborate a bit, if you want to do everything in a coroutine and then return:
@gen.coroutine
def submit(gremlinServerURI, traversalString):
output = []
response = yield submit(gremlinServerURI, traversalString)
while True:
result = yield response.read()
if result is None:
break
output.append(result.data)
raise gen.Return(output)
But the a more typical use case is with a async Python framework, for example, with Tornado something like:
class MainHandler(tornado.web.RequestHandler):
def get(self):
response = yield submit(gremlinServerURI, traversalString)
while True:
result = yield response.read()
if result is None:
self.finish()
self.write(resp.data)
from gremlinclient.
Related Issues (9)
- response API use pattern HOT 1
- InvalidStateError on stream.read() for message with 206 status HOT 1
- Example returns 400 HOT 11
- Message decoding check required. HOT 5
- Runtime Errors on non 2** response HOT 2
- How to use library with existing Tornado web app HOT 5
- `log` module hijacks the configuration of the root logger HOT 2
- Some problems HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gremlinclient.