'Return the registry for the given database name.'

def __new__(cls, db_name):

    with cls._lock:
        try:
            return cls.registries[db_name]
        except KeyError:
            return cls.new(db_name)
        finally:
            threading.current_thread().dbname = db_name
