ArangoDB-Community / pyArango

Python Driver for ArangoDB with built-in validation
https://pyarango.readthedocs.io/en/latest/
Apache License 2.0
238 stars 90 forks source link

Adding timeout to session object for hanging connections #242

Closed joeltgray closed 1 year ago

joeltgray commented 1 year ago

This PR should give PyArango users a greater level or granularity for dictating the http header timeout. Most users should not need to use this, but it will be extremely useful to have so those than do.

The use case I found personally was in a multinode Kubernetes configuration in the event of node death the connection would hang indefinitely but using this simple http header in the AikidoSesson object I was able to avoid this and the connection would sever itself after the allocated timeout.

I've included parameter in the standard Connection object so that users can access it easily without the need for excessive alternations to their code or the PyArango library.

Given that the likelihood of this connection issue is very minimal I think that a default timeout of 30 seconds should be fine and not affect any existing implementations. Furthermore if someone has already made monkey patch calls over the AikidoSesson object, they will still superceed any changes I have made here, rendering it safe for all users.

I have added a simple parameter test to ensure that the timeout value is propagated correctly through the code into the AikidoSesson itself.

joeltgray commented 1 year ago

Addresses concerns in #239

tariqdaouda commented 1 year ago

Thanks very useful.