[
https://issues.apache.org/jira/browse/TINKERPOP-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18131223#comment-18131223
]
ASF GitHub Bot commented on TINKERPOP-2774:
-------------------------------------------
masterhugo commented on code in PR #3527:
URL: https://github.com/apache/tinkerpop/pull/3527#discussion_r4365236506
##########
gremlin-python/src/main/python/gremlin_python/driver/async_driver_remote_connection.py:
##########
@@ -0,0 +1,297 @@
+#
+# 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.
+#
+import asyncio
+import logging
+import uuid
+
+from gremlin_python.driver.async_client import AsyncClient
+from gremlin_python.driver.remote_connection import RemoteConnection
+from gremlin_python.process.strategies import OptionsStrategy
+from gremlin_python.process.traversal import Bytecode
+
+log = logging.getLogger("gremlinpython")
+
+__author__ = 'Apache TinkerPop ([email protected])'
+
+
+class AsyncDriverRemoteConnection(RemoteConnection):
+ """Async remote connection backed by
:class:`~gremlin_python.driver.async_client.AsyncClient`.
+
+ Primary entry point for the async Gremlin driver. Works with
+ :func:`~gremlin_python.driver.async_graph_traversal.async_traversal` to
+ provide a fully 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()
+
+ **Robustness features**
+
+ * Per-connection WebSocket keepalive pings (see *ping_interval*).
+ * Automatic retry on network resets (handled inside
+ :class:`~gremlin_python.driver.async_client.AsyncClient`).
+ * *query_timeout* sets a default ``evaluationTimeout`` on every request.
+ * Session connections always attempt a rollback on ``close()`` to prevent
+ dangling transactions if the caller forgets to commit or roll back.
+
+ Parameters
+ ----------
+ url:
+ WebSocket endpoint, e.g. ``ws://localhost:8182/gremlin``.
+ traversal_source:
+ Gremlin traversal source name (default ``"g"``).
+ protocol_factory:
+ Forwarded to :class:`~gremlin_python.driver.async_client.AsyncClient`.
+ transport_factory:
+ Forwarded to :class:`~gremlin_python.driver.async_client.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``).
+ 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__(
Review Comment:
Updated, added the missing parameters and forwarded them in create_session()
as well.
> 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)