GumpacG commented on code in PR #3396:
URL: https://github.com/apache/tinkerpop/pull/3396#discussion_r3185107318
##########
gremlin-python/src/main/python/gremlin_python/driver/connection.py:
##########
@@ -82,19 +119,58 @@ def cb(f):
def _receive(self):
try:
- '''
- GraphSON does not support streaming deserialization, we are
aggregating data and bypassing streamed
- deserialization while GraphSON is enabled for testing. Remove
after GraphSON is removed.
- '''
- self._protocol.data_received_aggregate(self._transport.read(),
self._result_set)
- # re-enable streaming after graphSON removal
- # self._transport.read(self.stream_chunk)
+ # Check for non-GraphBinary error responses
+ status = getattr(self._transport, 'status_code', None)
+ if status is not None and status >= 400:
+ content_type = getattr(self._transport, 'content_type', '')
+ if 'graphbinary' not in content_type:
+ body = self._transport.read_body().decode('utf-8',
errors='replace')
+ raise GremlinServerError({
+ 'code': status,
+ 'message': body,
+ 'exception': ''
+ })
+
+ # 204 No Content
+ if status == 204:
+ return
+
+ stream = self._transport.get_stream()
+ reader = GraphBinaryReader()
+
+ # Read GB response header
+ stream.read(1) # version byte
+ flags = stream.read(1)[0]
+ bulked = flags == 0x01
+
+ # Deserialize results one at a time into the ResultSet
+ while True:
+ obj = reader.to_object(stream)
+ if obj == Marker.end_of_stream():
+ break
+ if bulked:
+ bulk = reader.to_object(stream)
+ for _ in range(bulk):
+ self._result_set.stream.put_nowait(obj)
+ else:
+ self._result_set.stream.put_nowait(obj)
+
+ # Read status after EndOfStream
+ status_code = int32_unpack(stream.read(4))
+ msg_is_null = stream.read(1)[0] == 0x01
+ status_message = '' if msg_is_null else reader.to_object(stream,
DataType.string, False)
+ exc_is_null = stream.read(1)[0] == 0x01
+ status_exception = '' if exc_is_null else reader.to_object(stream,
DataType.string, False)
+
+ if status_code not in (0, 200, 204):
Review Comment:
Good catch! No there isn't. Removed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]