(self)
Get and memoize connections to instances
Get and memoize connections to instances
Get and memoize connections to instances
def _connect(self):
        """Get and memoize connections to instances"""
        if self.db and self.db.closed:
            # Reset the connection object to retry to connect
            self.db = None

        if self.db:
            if self.db.status != psycopg2.extensions.STATUS_READY:
                # Some transaction went wrong and the connection is in an unhealthy state. Let's fix that
                self.db.rollback()
        else:
            self.db = self._new_connection(self._config.dbname)
def _connect ( self ) : if self . db and self . db . closed : # Reset the connection object to retry to connect self . db = None if self . db : if self . db . status != psycopg2 . extensions . STATUS_READY : # Some transaction went wrong and the connection is in an unhealthy state. Let's fix that self . db . rollback ( ) else : self . db = self . _new_connection ( self . _config . dbname )