You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any better way of getting a connection object that automatically reconnects than below? Closed connections keep throwing exceptions in random places in my code. I really don't care if my connection closed itself for whatever reason, I just want queries to run, so I'm trying to implement something like this 👍
an instance patch
import types
c = r.connect()
def auto_reconnect(self):
if self._instance is None or not self._instance.is_open():
self.reconnect()
c.check_open = types.MethodType( auto_reconnect, c )
c.close()
# Succeeds
r.db('simulator').table('watch_list').count().run(c)
or a general monkey patch
from rethinkdb import Connection
def auto_reconnect(self):
if self._instance is None or not self._instance.is_open():
self.reconnect()
Connection.check_open = auto_reconnect
The text was updated successfully, but these errors were encountered:
I am also very interested in a smart reconnect way for the python rethinkdb driver. You script seems to be it, but the import does not know types or Connection.
Is there any better way of getting a connection object that automatically reconnects than below? Closed connections keep throwing exceptions in random places in my code. I really don't care if my connection closed itself for whatever reason, I just want queries to run, so I'm trying to implement something like this 👍
an instance patch
or a general monkey patch
The text was updated successfully, but these errors were encountered: