You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Mark Br...e (Jira)" <ji...@apache.org> on 2020/06/30 12:30:00 UTC

[jira] [Commented] (TINKERPOP-1886) Gremlin Python driver to periodically issue ping / heartbeat to gremlin server

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

Mark Br...e commented on TINKERPOP-1886:
----------------------------------------

I had a look at what would be needed to change gremlin-python to allow the built in websocket ping to work, i.e. having a long-running thread to own the IOLoop.  It'd be a significant restructuring, because as previously described the IOLoop is started & stopped for each request (and then again for the response) by whichever ThreadPoolExecutor thread happens to be handling the request. 

The current design does a pretty good job of abstracting Tornado so in theory something else could be plugged in (and I guess works with Python 2.7 and older versions of Tornado).  But it does use the IOLoop in a number of different threads which is perhaps against the spirit of IOLoop, although not the letter because the [docs|https://www.tornadoweb.org/en/branch5.1/ioloop.html#tornado.ioloop.IOLoop] say not to share them across _processes_.

We'd probably want to spawn a daemon thread to run a single IOLoop and use it for all the connections in the pool, while continuing to use ThreadPoolExecutor for the de/serialization.  Then we'd need to put [add_callback|https://www.tornadoweb.org/en/branch5.1/ioloop.html#tornado.ioloop.IOLoop.add_callback] calls in at the right places to make requests and responses happen.  I think this would tie the implementation more directly to Tornado.  Or, we could do it on 3.5 and just use native Python 3.7+ `async` and remove Tornado?  There might be a performance hit from extra context switching, as well.

This daemon thread wouldn't receive any CPU time in "serverless" environments like AWS Lambda so pings wouldn't work there, but otherwise making this change should get pings going.  If there's enough interest in terms of upvotes I may be able to have a stab at this.

> Gremlin Python driver to periodically issue ping / heartbeat to gremlin server
> ------------------------------------------------------------------------------
>
>                 Key: TINKERPOP-1886
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1886
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: python
>    Affects Versions: 3.3.1
>            Reporter: Harshvardhan
>            Priority: Major
>
> Gremlin Python driver currently  does not send any ping request to the gremlin server. As a result, the websocket channel gets closed by the HAProxy load balancer after a period of inactivity.
>  
> Workarounds have been suggested in the discussion listed below.
> Link to google groups discussion: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/gremlin-users/bMs3OUPlBQI/q3fYU-9BBAAJ



--
This message was sent by Atlassian Jira
(v8.3.4#803005)