You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Cole Greer (Jira)" <ji...@apache.org> on 2023/01/04 23:13:00 UTC

[jira] [Updated] (TINKERPOP-2846) Different Behavior in Response to Close Frames in Python

     [ https://issues.apache.org/jira/browse/TINKERPOP-2846?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Cole Greer updated TINKERPOP-2846:
----------------------------------
    Description: 
Typically if a gremlin client receives a close websocket frame from the server, it will mark the current connection as dead, and attempt to create a new connection. The python GLV does not replicate this behavior, it appears that upon receiving a close web socket frame, the underlying asyncio event loop in the transporter is closed and no attempt to reconnect is made. Further, awareness of this closed state does not propagate back up to the client level as client.is_closed() will still return false. Any future requests made through this client will fail as the underlying event loop is closed.

This behavior is demonstrated in this test from [https://github.com/apache/tinkerpop/blob/master/gremlin-python/src/main/python/tests/driver/test_web_socket_client_behavior.py]
{code:java}
def test_does_not_create_new_connection_if_closed_by_server(socket_server_client, socket_server_settings):
        
        
              try:
        
        
                  socket_server_client.submit(
        
        
                      "1", request_options={'requestId': socket_server_settings["CLOSE_CONNECTION_REQUEST_ID"]}).all().result()
        
        
              except RuntimeError as err:
        
        
                  assert str(err) == "Connection was closed by server."
        
        
          

        
        
              assert not socket_server_client.is_closed()
        
        
          

        
        
              try:
        
        
                  response = socket_server_client.submit(
        
        
                      "1", request_options={'requestId': socket_server_settings["SINGLE_VERTEX_REQUEST_ID"]}).all().result()
        
        
              except RuntimeError as err:
        
        
                  assert str(err) == "Event loop is closed"
        
        
          

        
        
              assert not socket_server_client.is_closed() {code}

  was:Typically if a gremlin client receives a close websocket frame from the server, it will mark the current connection as dead, and attempt to create a new connection. The python GLV does not replicate this behavior, it appears that upon receiving a close web socket frame, the underlying asyncio event loop in the transporter is closed and no attempt to reconnect is made. Further, awareness of this closed state does not propagate back up to the client level as client.is_closed() will still return false. Any future requests made through this client will fail as the underlying event loop is closed. In the near future, I will be submitting a PR as part of [TINKERPOP-2819|https://issues.apache.org/jira/browse/TINKERPOP-2819] which contains a test demonstrating this behavior.


> Different Behavior in Response to Close Frames in Python
> --------------------------------------------------------
>
>                 Key: TINKERPOP-2846
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2846
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: python
>    Affects Versions: 3.7.0
>            Reporter: Cole Greer
>            Priority: Major
>
> Typically if a gremlin client receives a close websocket frame from the server, it will mark the current connection as dead, and attempt to create a new connection. The python GLV does not replicate this behavior, it appears that upon receiving a close web socket frame, the underlying asyncio event loop in the transporter is closed and no attempt to reconnect is made. Further, awareness of this closed state does not propagate back up to the client level as client.is_closed() will still return false. Any future requests made through this client will fail as the underlying event loop is closed.
> This behavior is demonstrated in this test from [https://github.com/apache/tinkerpop/blob/master/gremlin-python/src/main/python/tests/driver/test_web_socket_client_behavior.py]
> {code:java}
> def test_does_not_create_new_connection_if_closed_by_server(socket_server_client, socket_server_settings):
>         
>         
>               try:
>         
>         
>                   socket_server_client.submit(
>         
>         
>                       "1", request_options={'requestId': socket_server_settings["CLOSE_CONNECTION_REQUEST_ID"]}).all().result()
>         
>         
>               except RuntimeError as err:
>         
>         
>                   assert str(err) == "Connection was closed by server."
>         
>         
>           
>         
>         
>               assert not socket_server_client.is_closed()
>         
>         
>           
>         
>         
>               try:
>         
>         
>                   response = socket_server_client.submit(
>         
>         
>                       "1", request_options={'requestId': socket_server_settings["SINGLE_VERTEX_REQUEST_ID"]}).all().result()
>         
>         
>               except RuntimeError as err:
>         
>         
>                   assert str(err) == "Event loop is closed"
>         
>         
>           
>         
>         
>               assert not socket_server_client.is_closed() {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)