# myapp/tasks.py from chongming_task import task @task(tags={"io"}) def worker(ctx, source: str) -> int: """常驻消费。""" processed = 0 while not ctx.is_stop_requested: # ← 优雅收尾(终态 succeeded,返回值保留) ctx.checkpoint() # ← 不调用它 = 停不掉 processed += 1 ctx.progress(processed, unit="batch") return processed def register(controller): # 或者不写它,只靠 @task 也行 controller.register_module(__import__(__name__))