24 lines
682 B
Python
24 lines
682 B
Python
|
|
"""批次暂停/等待规则与创建流程分离,避免工作流和批次服务反向依赖。"""
|
||
|
|
|
||
|
|
from app.models import Batch
|
||
|
|
|
||
|
|
|
||
|
|
def member_holds(holds, b, waiting):
|
||
|
|
holds = set(holds or []) | set(b.hold_reasons or [])
|
||
|
|
if b.desired_state == "pause":
|
||
|
|
holds.add("batch_pause")
|
||
|
|
else:
|
||
|
|
holds.discard("batch_pause")
|
||
|
|
if waiting:
|
||
|
|
holds.add("batch_wait")
|
||
|
|
else:
|
||
|
|
holds.discard("batch_wait")
|
||
|
|
return holds
|
||
|
|
|
||
|
|
|
||
|
|
async def run_member_holds(s, r):
|
||
|
|
b = await s.get(Batch, r.batch_id)
|
||
|
|
if b is None or b.deleted_at is not None:
|
||
|
|
return set(r.hold_reasons or []) | {"batch_wait"}
|
||
|
|
return member_holds(r.hold_reasons, b, False)
|