0

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.

Toussah
  • 245
  • 1
  • 3
  • 14

1 Answers1

1

Found the answer by digging through the source code of gremlinpython and aiohttp.

The kwargs passed to DriverRemoteConnection are passed to AiohttpTransport. So the proper way to pass connection and request timeout parameters is as such:

driver_remote_connection = DriverRemoteConnection(
    self.conn,
    pool_size=self.pool_size,
    max_workers=self.max_workers,
    timeout=gremlin_connect_timeout_secs,
    read_timeout=gremlin_request_timeout_secs,
)
Toussah
  • 245
  • 1
  • 3
  • 14
  • 1
    Those are the transport level timeouts. Worth mentioning for anyone else finding this question that there is also a separate query timeout that can be specified as part of the query itself. – Kelvin Lawrence Mar 03 '22 at 17:05