From 7d0a83c197867ddb14411732ff741f4d9ded6bc3 Mon Sep 17 00:00:00 2001
From: davebshow <davebshow@gmail.com>
Date: Mon, 22 Jan 2018 15:47:00 -0800
Subject: [PATCH] cleaner approach to deserialization

---
 aiogremlin/driver/protocol.py                                  | 3 +--
 .../driver/test_driver_remote_connection.py                    | 1 +
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/aiogremlin/driver/protocol.py b/aiogremlin/driver/protocol.py
index 97f1292..f1f521c 100644
--- a/aiogremlin/driver/protocol.py
+++ b/aiogremlin/driver/protocol.py
@@ -43,7 +43,7 @@ class GremlinServerWSProtocol(protocol.AbstractBaseProtocol):
 
     async def data_received(self, data, results_dict):
         data = data.decode('utf-8')
-        message = json.loads(data)
+        message = self._message_serializer.deserialize_message(json.loads(data))
         request_id = message['requestId']
         status_code = message['status']['code']
         data = message['result']['data']
@@ -65,7 +65,6 @@ class GremlinServerWSProtocol(protocol.AbstractBaseProtocol):
             else:
                 if data:
                     for result in data:
-                        result = self._message_serializer.deserialize_message(result)
                         message = Message(status_code, result, msg)
                         result_set.queue_result(message)
                 else:
diff --git a/tests/test_gremlin_python/driver/test_driver_remote_connection.py b/tests/test_gremlin_python/driver/test_driver_remote_connection.py
index 2cdbe84..883d4c1 100644
--- a/tests/test_gremlin_python/driver/test_driver_remote_connection.py
+++ b/tests/test_gremlin_python/driver/test_driver_remote_connection.py
@@ -38,6 +38,7 @@ class TestDriverRemoteConnection(object):
         statics.load_statics(globals())
         g = Graph().traversal().withRemote(remote_connection)
         result = await g.V().limit(1).toList()
+        await remote_connection.close()
 
     @pytest.mark.asyncio
     async def test_traversals(self, remote_connection):
-- 
GitLab