[ 
https://issues.apache.org/jira/browse/TINKERPOP-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146774#comment-18146774
 ] 

ASF GitHub Bot commented on TINKERPOP-2774:
-------------------------------------------

masterhugo commented on code in PR #3527:
URL: https://github.com/apache/tinkerpop/pull/3527#discussion_r4615329235


##########
gremlin-python/src/main/python/gremlin_python/driver/async_client.py:
##########
@@ -0,0 +1,326 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+"""Experimental API. This API may have breaking changes or be removed in a 
subsequent minor release.
+
+Native-async Gremlin client using WebSocket transport.
+"""
+import asyncio
+import logging
+
+from gremlin_python.driver import request, serializer
+from gremlin_python.driver.async_connection import AsyncConnection
+from gremlin_python.driver.async_protocol import AsyncGremlinServerWSProtocol
+from gremlin_python.driver.aiohttp.async_transport import 
AsyncAiohttpWSTransport
+from gremlin_python.process import traversal
+
+log = logging.getLogger("gremlinpython")
+
+
+class AsyncClient:
+    """Experimental API. This API may have breaking changes or be removed in a 
subsequent minor release.
+
+    Native-async Gremlin client using WebSocket transport.
+
+    The connection pool is an asyncio.Queue and all submit/close methods are
+    coroutines that must be awaited.
+
+    Features:
+
+    * Each connection runs a background WebSocket ping to prevent idle
+      disconnects (configurable via ping_interval).
+    * default_request_options are merged into every request so options
+      like evaluationTimeout can be set once per client.
+
+    Usage::
+
+        async with AsyncClient("ws://localhost:8182/gremlin", "g") as client:
+            result_set = await client.submit("g.V().count()")
+            print(await result_set.all())
+
+    Parameters
+    ----------
+    url:
+        WebSocket endpoint, e.g. ws://localhost:8182/gremlin.
+    traversal_source:
+        Gremlin traversal source name (default "g").
+    protocol_factory:
+        Zero-argument callable returning an AsyncGremlinServerWSProtocol.
+    transport_factory:
+        Zero-argument callable returning an AsyncAiohttpWSTransport.
+    pool_size:
+        Number of concurrent WebSocket connections (default 8; forced to 1
+        in session mode).
+    message_serializer:
+        Serializer to use (default GraphBinarySerializersV1).
+    username, password:
+        Credentials for SASL/basic authentication.
+    kerberized_service:
+        Kerberos service principal for Kerberos authentication.
+    headers:

Review Comment:
   Applied the documentation update on AsyncClient, 
AsyncDriverRemoteConnection, and AsyncConnection to clarify that headers must 
be a mutable mapping (dict[str, str]) and list-of-pair headers are not 
supported. Let me know if there is anything else to adjust!





> Full async/await support in gremlin-python
> ------------------------------------------
>
>                 Key: TINKERPOP-2774
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2774
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: python
>    Affects Versions: 3.5.3
>            Reporter: Ken Hu
>            Priority: Minor
>
> Recently, there have been multiple instances of users asking about issues 
> with event loops and aiohttp. This discussion nearly always ends up with the 
> user requesting for async/await support in gremlin-python. This means full 
> compatibility with asyncio and not needing to use threads.
> Async/await support is also a feature that those using newer, asynchronous 
> web frameworks are asking for as gremlin-python can be a performance 
> bottleneck due to its lack of support for async/await.
> My intention is that we can use this issue as a means of gauging the interest 
> from the community for this feature. If you are interested in having 
> gremlin-python support async/await then please leave a comment below.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to