Giter VIP home page Giter VIP logo

Comments (2)

davebshow avatar davebshow commented on September 21, 2024

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.

davebshow avatar davebshow commented on September 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.