'GremlinPython add connection and request timeout to DriverRemoteConnection with aiohttp

I am upgrading the gremlinpython package from 3.4 to 3.5

As part of the upgrade, tornado has been removed and only aiohttp is supported.

Before, to create a DriverRemoteConnection with a connection and request timeout, I used the following code

from tornado import httpclient

req = httpclient.HTTPRequest(
    connection_str,
    connect_timeout=gremlin_connect_timeout_secs, 
    request_timeout=gremlin_request_timeout_secs
)
driver_remote_connection = DriverRemoteConnection(
    req, "g", pool_size=pool_size, max_workers=max_workers
)
g = traversal().withRemote(driver_remote_connection)

Now that tornado isn't supported anymore, what would be the equivalent in 3.5+?

My connection is to AWS Neptune.

I've looked into the aiogremlin package and the aiohttp library but it requires me to create asynchronous client while I don't need for the connection to be asynchronous.

I can create the DriverRemoteConnection with simply this

driver_remote_connection = DriverRemoteConnection(
    self.conn, pool_size=self.pool_size, max_workers=self.max_workers
)

But then I'm not able to pass a connection/request timeout.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source