TINKERPOP-1913 Added status attributes to ResultSet for python
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index e1b75dd..386f0d9 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -38,11 +38,10 @@
* Bumped to Netty 4.1.25.
* Bumped to Spark 2.3.1.
* Modified Gremlin Server to return a "host" status attribute on responses.
-* Added ability to the Java driver to retrieve status attributes returned from the server on the `ResultSet` object.
-* Modified remote traversals to retreive status attributes from traversal side-effects.
+* Added ability to the Java, .NET and Python drivers to retrieve status attributes returned from the server on the `ResultSet` object.
+* Modified remote traversals to retrieve status attributes from traversal side-effects.
* Deprecated two `submit()`-related methods on the Java driver `Client` class.
-* Modified Gremlin.Net `ResponseException` to include status code and status attributes.
-* Modified Java driver's `ResponseException` to include status code and status attributes.
+* Modified Java and Gremlin.Net `ResponseException` to include status code and status attributes.
* Modified the return type for `IGremlinClient.SubmitAsync()` to be a `ResultSet` rather than an `IReadOnlyCollection`.
* Added `Client.submit()` overloads that accept per-request `RequestOptions`.
* Added sparql-gremlin.
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
index e0a2f7e..96174e0 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
@@ -90,6 +90,7 @@
elif status_code in [200, 206]:
result_set.stream.put_nowait(data)
if status_code == 200:
+ result_set.status_attributes = message['status']['attributes']
del results_dict[request_id]
return status_code
else:
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py b/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
index cfdca5b..76e5029 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
@@ -28,6 +28,7 @@
self._request_id = request_id
self._done = None
self._aggregate_to = None
+ self._status_attributes = {}
@property
def aggregate_to(self):
@@ -38,6 +39,14 @@
self._aggregate_to = val
@property
+ def status_attributes(self):
+ return self._status_attributes
+
+ @status_attributes.setter
+ def status_attributes(self, val):
+ self._status_attributes = val
+
+ @property
def request_id(self):
return self._request_id
diff --git a/gremlin-python/src/main/jython/tests/driver/test_client.py b/gremlin-python/src/main/jython/tests/driver/test_client.py
index fbfe2d7..44dc3a7 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_client.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_client.py
@@ -19,6 +19,7 @@
import pytest
from gremlin_python.driver.client import Client
+from gremlin_python.driver.protocol import GremlinServerError
from gremlin_python.driver.request import RequestMessage
from gremlin_python.process.graph_traversal import __
from gremlin_python.structure.graph import Graph
@@ -35,6 +36,8 @@
results = future.result()
assert len(results) == 6
assert isinstance(results, list)
+ assert results_set.done.done()
+ assert 'host' in results_set.status_attributes
def test_client_simple_eval(client):