mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-23 18:21:42 +08:00
batches.py: Don't pass SQLAlchemy objects between threads
SQLAlchemy objects can't be used from multiple threads - so when starting threads for builds, pass the ComponentBuild id rather than the object. (Note that despite the comment that the threads were sharing a session, they weren't - what was passed to the thread was a scoped_session that acts as a separate thread-local session per-thread.) BUILD_COMPONENT_DB_SESSION_LOCK - a threading.Lock() object that was used in a few places - but not nearly enough places to effectively lock usage of a shared session - is removed.
This commit is contained in:
@@ -1107,6 +1107,10 @@ class ComponentBuild(MBSBase):
|
||||
Index("idx_component_builds_build_id_nvr", "module_id", "nvr", unique=True),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_id(cls, db_session, component_build_id):
|
||||
return db_session.query(cls).filter(cls.id == component_build_id).first()
|
||||
|
||||
@classmethod
|
||||
def from_component_event(cls, db_session, task_id, module_id=None):
|
||||
_filter = db_session.query(cls).filter
|
||||
|
||||
Reference in New Issue
Block a user