(self, dbname)
Returns a memoized psycopg2 connection to `dbname` with autocommit
        Threadsafe as long as no transactions are used
        :param dbname:
        :return: a psycopg2 connection
Returns a memoized psycopg2 connection to `dbname` with autocommit
        Threadsafe as long as no transactions are used
        :param dbname:
        :return: a psycopg2 connection
Returns a memoized psycopg2 connection to dbname with autocommit Threadsafe as long as no transactions are used : param dbname : : return : a psycopg2 connection
def _get_db(self, dbname):
        """
        Returns a memoized psycopg2 connection to `dbname` with autocommit
        Threadsafe as long as no transactions are used
        :param dbname:
        :return: a psycopg2 connection
        """
        # TODO: migrate the rest of this check to use a connection from this pool
        with self._db_pool_lock:
            db = self._db_pool.get(dbname)
            if not db or db.closed:
                self.log.debug("initializing connection to dbname=%s", dbname)
                db = self._new_connection(dbname)
                db.set_session(autocommit=True)
                self._db_pool[dbname] = db
                if self._config.dbname == dbname:
                    # reload settings for the main DB only once every time the connection is reestablished
                    self._load_pg_settings(db)
            if db.status != psycopg2.extensions.STATUS_READY:
                # Some transaction went wrong and the connection is in an unhealthy state. Let's fix that
                db.rollback()
            return db
def _get_db ( self , dbname ) : # TODO: migrate the rest of this check to use a connection from this pool with self . _db_pool_lock : db = self . _db_pool . get ( dbname ) if not db or db . closed : self . log . debug ( "initializing connection to dbname=%s" , dbname ) db = self . _new_connection ( dbname ) db . set_session ( autocommit = True ) self . _db_pool [ dbname ] = db if self . _config . dbname == dbname : # reload settings for the main DB only once every time the connection is reestablished self . _load_pg_settings ( db ) if db . status != psycopg2 . extensions . STATUS_READY : # Some transaction went wrong and the connection is in an unhealthy state. Let's fix that db . rollback ( ) return db