Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-1599

implement real gremlin-python driver



    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.3
    • 3.2.5
    • python
    • None


      It is high time that gremlin-python comes packaged with a real driver. After watching the community discussion, it seems that the way to go will be to use the concurrent.futures module with multithreading to provide asynchronous I/O. While the default underlying websocket client library will remain Tornado due to Python 2/3 compatibility issues, this should be decoupled from the rest of the client and easy to replace.

      With this is mind, I created a baseline client implementation with this commit in a topic branch python_driver. Some things to note:

      • All I/O is performed using the concurrent.futures module, which provides a standard 2/3 compatible future interface.
      • The implementation currently does not include the concept of a cluster, instead it assumes a single host.
      • The transport interface makes it easy to plug in client libraries by defining a simple wrapper.
      • Because this is an example, I didn't fix all the tests to work with the new client implementation. Instead I just added a few demo tests. If we decide to move forward with this I will update the original tests.

      The resulting API looks like this for a simple client:

      client = Client('ws://localhost:8182/gremlin', 'g')
      g = Graph().traversal()
      t = g.V()
      future_result_set = client.submitAsync(t.bytecode)
      result_set = future_result_set.result()
      results = result_set.all().result()

      Using the DriverRemoteConnection:

      conn = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g')
      g = Graph().traversal().withRemote(conn)
      t = g.V()
      results = t.toList()

      If you have a minute to check out the new driver code that would be great, I welcome feedback and suggestions. If we decide to move forward like this, I will proceed to finish the driver implementation.


        Issue Links



              davebshow David Brown
              davebshow David Brown
              0 Vote for this issue
              4 Start watching this issue