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

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

lyndonb-bq commented on a change in pull request #1571:
URL: https://github.com/apache/tinkerpop/pull/1571#discussion_r810221316



##########
File path: 
gremlin-python/src/main/python/gremlin_python/driver/driver_remote_connection.py
##########
@@ -74,7 +79,19 @@ def __init__(self, url, traversal_source="g", 
protocol_factory=None,
         self._traversal_source = self._client._traversal_source
 
     def close(self):
-        logging.info("closing DriverRemoteConnection with url '%s'", 
str(self._url))
+        # close this client and any DriverRemoteConnection instances spawned 
from this one
+        # for a session
+        if len(self.__spawned_sessions) > 0:
+            logging.info("closing spawned sessions from DriverRemoteConnection 
with url '%s'", str(self._url))
+            for spawned_session in self.__spawned_sessions:
+                spawned_session.close()
+
+        if self.__session:
+            logging.info("closing DriverRemoteConnection with url '%s' with 
session '%s'",
+                         str(self._url), self.__session)

Review comment:
       Does this print correctly? I thought the session object in the 
DriverRemoteConnection class was technical a uuid object, I am wondering if 
self.__session should be wrapped in an `str` like so:
   ```suggestion
                            str(self._url), str(self.__session))
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


> Closing parent connection in python should close tx() connections
> -----------------------------------------------------------------
>
>                 Key: TINKERPOP-2707
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2707
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: python
>    Affects Versions: 3.5.2
>            Reporter: Stephen Mallette
>            Priority: Blocker
>
> If you do:
> {code}
> graph=Graph()
> connection = DriverRemoteConnection(endpoint,'g',
>                  
> transport_factory=lambda:AiohttpTransport(call_from_event_loop=True))
> g = graph.traversal().withRemote(connection)
> tx = g.tx()
> gtx = tx.begin()
> try:
>     id1 = gtx.addV('id1').next()
>     id2 = gtx.addV('id2').next()
> except Exception as e:
>     tx.rollback()
> else:
>     print(id1,id2)
>               
> connection.close()
> {code}
> The connection in {{tx}} won't be closed and it will be up to the server to 
> timeout the connection in its normal fashion. While this isn't the expected 
> way {{tx}} should be used, it is a bit of a hole someone could stumble in. 
> Seems like, the close of the parent {{connection}} should also close any 
> spawned child connections. It might be worth looking at Java to see how the 
> implementation works there as well.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to