This is an automated email from the ASF dual-hosted git repository.
xiazcy 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 cd6bcee936 CTR minor update in gremlin-python error handling and test
setup
cd6bcee936 is described below
commit cd6bcee936ebd33a2769d2c5d504614f154919be
Author: Yang Xia <[email protected]>
AuthorDate: Fri Nov 8 13:54:44 2024 -0800
CTR minor update in gremlin-python error handling and test setup
---
.../main/python/gremlin_python/driver/aiohttp/transport.py | 6 ++++++
.../src/main/python/gremlin_python/driver/connection.py | 4 +---
.../src/main/python/gremlin_python/process/traversal.py | 13 -------------
gremlin-python/src/main/python/tests/conftest.py | 6 +++++-
4 files changed, 12 insertions(+), 17 deletions(-)
diff --git
a/gremlin-python/src/main/python/gremlin_python/driver/aiohttp/transport.py
b/gremlin-python/src/main/python/gremlin_python/driver/aiohttp/transport.py
index 399f6806b8..459eeebc28 100644
--- a/gremlin-python/src/main/python/gremlin_python/driver/aiohttp/transport.py
+++ b/gremlin-python/src/main/python/gremlin_python/driver/aiohttp/transport.py
@@ -16,6 +16,8 @@
# specific language governing permissions and limitations
# under the License.
#
+import json
+
import aiohttp
import asyncio
import sys
@@ -123,6 +125,10 @@ class AiohttpHTTPTransport(AbstractBaseTransport):
if self._max_content_len and len(
data_buffer) > self._max_content_len:
raise Exception(f'Response size {len(data_buffer)}
exceeds limit {self._max_content_len} bytes')
+ if self._http_req_resp.headers.get('content-type') ==
'application/json':
+ message = json.loads(data_buffer.decode('utf-8'))
+ err = message.get('message')
+ raise Exception(f'Server disconnected with error
message: "{err}" - please try to reconnect')
return data_buffer
return self._loop.run_until_complete(async_read())
# raise Exception('missing handling of streamed responses to
protocol')
diff --git a/gremlin-python/src/main/python/gremlin_python/driver/connection.py
b/gremlin-python/src/main/python/gremlin_python/driver/connection.py
index 434272c5c5..79b688e89b 100644
--- a/gremlin-python/src/main/python/gremlin_python/driver/connection.py
+++ b/gremlin-python/src/main/python/gremlin_python/driver/connection.py
@@ -42,9 +42,7 @@ class Connection:
self.__add_header(useragent.userAgentHeader, useragent.userAgent)
self._enable_bulked_result = enable_bulked_result
if self._enable_bulked_result:
- if self._headers is None:
- self._headers = dict()
- self._headers["bulked"] = "true"
+ self.__add_header("bulked", "true")
def connect(self):
if self._transport:
diff --git a/gremlin-python/src/main/python/gremlin_python/process/traversal.py
b/gremlin-python/src/main/python/gremlin_python/process/traversal.py
index bc37dc0506..bed20abc0b 100644
--- a/gremlin-python/src/main/python/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/python/gremlin_python/process/traversal.py
@@ -203,19 +203,6 @@ statics.add_static('BOTH', Direction.BOTH)
statics.add_static('from_', Direction.OUT)
statics.add_static('to', Direction.IN)
-# TODO to be removed
-GraphSONVersion = Enum('GraphSONVersion', ' V1_0 V2_0 V3_0')
-
-statics.add_static('V1_0', GraphSONVersion.V1_0)
-statics.add_static('V2_0', GraphSONVersion.V2_0)
-statics.add_static('V3_0', GraphSONVersion.V3_0)
-
-# TODO to be removed
-GryoVersion = Enum('GryoVersion', ' V1_0 V3_0')
-
-statics.add_static('V1_0', GryoVersion.V1_0)
-statics.add_static('V3_0', GryoVersion.V3_0)
-
DT = Enum('DT', ' second minute hour day')
statics.add_static('second', DT.second)
diff --git a/gremlin-python/src/main/python/tests/conftest.py
b/gremlin-python/src/main/python/tests/conftest.py
index cc958c7c5d..918e6aa34c 100644
--- a/gremlin-python/src/main/python/tests/conftest.py
+++ b/gremlin-python/src/main/python/tests/conftest.py
@@ -134,11 +134,15 @@ def remote_connection(request):
return remote_conn
[email protected](params=['graphbinaryv4'])
[email protected](params=['graphbinaryv4','graphsonv4'])
def remote_connection_crew(request):
try:
if request.param == 'graphbinaryv4':
remote_conn = DriverRemoteConnection(anonymous_url, 'gcrew')
+ elif request.param == 'graphsonv4':
+ remote_conn = DriverRemoteConnection(anonymous_url, 'gcrew',
+
request_serializer=serializer.GraphSONSerializersV4(),
+
response_serializer=serializer.GraphSONSerializersV4())
else:
raise ValueError("Invalid serializer option - " + request.param)
except OSError: