You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/05/18 22:42:01 UTC

[02/30] tinkerpop git commit: Don't use recursive calls for streaming response

Don't use recursive calls for streaming response


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4c8717dd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4c8717dd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4c8717dd

Branch: refs/heads/TINKERPOP-1595
Commit: 4c8717dd4e94ec248a959911d8c11f3b45b2d7b3
Parents: 268423d
Author: davebshow <da...@gmail.com>
Authored: Mon Apr 23 16:21:48 2018 -0700
Committer: davebshow <da...@gmail.com>
Committed: Mon Apr 23 16:21:48 2018 -0700

----------------------------------------------------------------------
 .../src/main/jython/gremlin_python/driver/connection.py      | 7 +++++--
 .../src/main/jython/gremlin_python/driver/protocol.py        | 8 ++++----
 2 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4c8717dd/gremlin-python/src/main/jython/gremlin_python/driver/connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/connection.py
index abc4545..bff1904 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/connection.py
@@ -73,6 +73,9 @@ class Connection:
         return future
 
     def _receive(self):
-        data = self._transport.read()
-        self._protocol.data_received(data, self._results)
+        while True:
+            data = self._transport.read()
+            status_code = self._protocol.data_received(data, self._results)
+            if status_code != 206:
+                break
         self._pool.put_nowait(self)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4c8717dd/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
----------------------------------------------------------------------
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 84a7d82..2fc7c1b 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
@@ -80,21 +80,21 @@ class GremlinServerWSProtocol(AbstractBaseProtocol):
                 {'sasl': base64.b64encode(auth).decode()})
             self.write(request_id, request_message)
             data = self._transport.read()
+            # Allow recursive call for auth
             self.data_received(data, results_dict)
         elif status_code == 204:
             result_set.stream.put_nowait([])
             del results_dict[request_id]
+            return status_code
         elif status_code in [200, 206]:
             results = []
             for msg in data["result"]["data"]:
                 results.append(
                     self._message_serializer.deserialize_message(msg))
             result_set.stream.put_nowait(results)
-            if status_code == 206:
-                data = self._transport.read()
-                self.data_received(data, results_dict)
-            else:
+            if status_code == 200:
                 del results_dict[request_id]
+            return status_code
         else:
             del results_dict[request_id]
             raise GremlinServerError(