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

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

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


##########
gremlin-python/src/main/python/gremlin_python/driver/async_driver_remote_connection.py:
##########
@@ -0,0 +1,369 @@
+#
+# 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.
+
+Asynchronous remote connection backed by AsyncClient.
+"""
+import asyncio
+import logging
+import uuid
+
+from gremlin_python.driver import serializer
+from gremlin_python.driver.async_client import AsyncClient
+from gremlin_python.process.strategies import OptionsStrategy
+from gremlin_python.process.traversal import Bytecode
+
+log = logging.getLogger("gremlinpython")
+
+
+class AsyncDriverRemoteConnection:
+    """Experimental API. This API may have breaking changes or be removed in a 
subsequent minor release.
+
+    Async remote connection backed by AsyncClient.
+
+    Primary entry point for the async Gremlin driver.  Works with
+    async_traversal() to provide an async traversal DSL::
+
+        async with AsyncDriverRemoteConnection("ws://localhost:8182/gremlin", 
"g") as rc:
+            g = async_traversal().with_remote(rc)
+            names = await g.V().has_label("person").values("name").to_list()
+
+    Features:
+
+    * Per-connection WebSocket keepalive pings (see *ping_interval*).
+    * *query_timeout* sets a default evaluationTimeout on every request.
+
+    Parameters
+    ----------
+    url:
+        WebSocket endpoint, e.g. ws://localhost:8182/gremlin.
+    traversal_source:
+        Gremlin traversal source name (default "g").
+    protocol_factory:
+        Forwarded to AsyncClient.
+    transport_factory:
+        Forwarded to AsyncClient.
+    pool_size:
+        Number of concurrent WebSocket connections (default 8).
+    message_serializer:
+        Serializer instance (default GraphBinarySerializersV1).
+    username, password:
+        Credentials for SASL/basic authentication.
+    kerberized_service:
+        Kerberos service principal.
+    headers:
+        Extra HTTP headers for every WebSocket handshake.
+    session:
+        Session UUID string to enable server-side sessions.
+    enable_user_agent_on_connect:
+        Send the driver user-agent header (default True).
+    enable_compression:
+        Enable WebSocket per-message deflate compression (default False).
+    graphson_reader, graphson_writer:
+        Optional custom GraphSON reader and writer used when
+        *message_serializer* is not explicitly provided.
+    ping_interval:
+        Seconds between keepalive pings (default 60, 0 to disable).
+    query_timeout:
+        Default query timeout in seconds applied to every request as
+        evaluationTimeout.  Per-request options override this.
+    **transport_kwargs:
+        Extra keyword arguments forwarded to the default transport.
+    """
+
+    def __init__(
+        self,
+        url,
+        traversal_source="g",
+        protocol_factory=None,
+        transport_factory=None,
+        pool_size=None,
+        message_serializer=None,
+        username="",
+        password="",
+        kerberized_service="",
+        headers=None,
+        session=None,
+        enable_user_agent_on_connect=True,
+        enable_compression=False,
+        graphson_reader=None,
+        graphson_writer=None,
+        ping_interval=60,
+        query_timeout=None,

Review Comment:
   Updated query_timeout to take milliseconds directly to match 
evaluationTimeout, along with the docstring and unit tests.





> 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