This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/master by this push:
     new 79b5e1c  TINKERPOP-2096 Throw GremlinServerError if server disconnects 
before read completes
     new 1fe46fe  Merge branch 'tp33'
79b5e1c is described below

commit 79b5e1cf169f7b9dd53d3c7e642f00d2a97dcc08
Author: Stephen Mallette <[email protected]>
AuthorDate: Wed Dec 19 12:29:54 2018 -0500

    TINKERPOP-2096 Throw GremlinServerError if server disconnects before read 
completes
    
    Prior to this change we'd get a more obscure looking AttributeError which 
didn't really explain what had happened. CTR
---
 CHANGELOG.asciidoc                                               | 1 +
 gremlin-python/src/main/jython/gremlin_python/driver/protocol.py | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index d8dc8bf..2aa3630 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -37,6 +37,7 @@ This release also includes changes from <<release-3-2-11, 
3.2.11>>.
 * Deprecated `TraversalSource#GREMLIN_REMOTE` and 
`TraversalSource#GREMLIN_REMOTE_CONNECTION_CLASS` moving them to 
`RemoteConnection`.
 * Fixed the setting of the default label for a `ReferenceVertex` when the 
original vertex was of type `ComputerAdjacentVertex`.
 * Changed Java driver to expect a generic `RemoteTraverser` object rather than 
the specific `DefaultRemoteTraverser`.
+* Better handled server disconnect condition for the `gremlin-python` driver 
by throwing a clear exception.
 * Display the remote stack trace in the Gremlin Console when scripts sent to 
the server fail.
 * Added `AnonymousTraversalSource` which provides a more unified means of 
constructing a `TraversalSource`.
 * Added `DriverRemoteConnection.using(Client)` to provide users better control 
over the number of connections being created.
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..7571217 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
@@ -66,6 +66,10 @@ class GremlinServerWSProtocol(AbstractBaseProtocol):
         self._transport.write(message)
 
     def data_received(self, message, results_dict):
+        # if Gremlin Server cuts off then we get a None for the message
+        if message is None:
+            raise GremlinServerError("Server disconnected - please try to 
reconnect")
+
         message = 
self._message_serializer.deserialize_message(json.loads(message.decode('utf-8')))
         request_id = message['requestId']
         result_set = results_dict[request_id]

Reply via email to