MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / _get_engine

Function _get_engine

registry.py:157–184  ·  view source on GitHub ↗

Get or create the database engine (thread-safe singleton pattern). Returns: Tuple of (engine, SessionLocal)

()

Source from the content-addressed store, hash-verified

155
156
157def _get_engine():
158 """
159 Get or create the database engine (thread-safe singleton pattern).
160
161 Returns:
162 Tuple of (engine, SessionLocal)
163 """
164 global _engine, _SessionLocal
165
166 # Double-checked locking for thread safety
167 if _engine is None:
168 with _engine_lock:
169 if _engine is None:
170 db_path = get_registry_path()
171 db_url = f"sqlite:///{db_path.as_posix()}"
172 _engine = create_engine(
173 db_url,
174 connect_args={
175 "check_same_thread": False,
176 "timeout": SQLITE_TIMEOUT,
177 }
178 )
179 Base.metadata.create_all(bind=_engine)
180 _migrate_add_default_concurrency(_engine)
181 _SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=_engine)
182 logger.debug("Initialized registry database at: %s", db_path)
183
184 return _engine, _SessionLocal
185
186
187def _migrate_add_default_concurrency(engine) -> None:

Callers 8

_get_sessionFunction · 0.85
get_project_pathFunction · 0.85
list_registered_projectsFunction · 0.85
get_project_infoFunction · 0.85
get_project_concurrencyFunction · 0.85
list_valid_projectsFunction · 0.85
get_settingFunction · 0.85
get_all_settingsFunction · 0.85

Calls 2

get_registry_pathFunction · 0.85

Tested by

no test coverage detected