1. Pierre-Yves David
  2. pyti-master

Commits

Pierre-Yves David  committed f9c2190

Add basic time out mechanism for ExecutionTarget

  • Participants
  • Parent commits 534e3f7
  • Branches default

Comments (0)

Files changed (1)

File hooks.py

View file
     finally:
         session.close()
 
+def cancel_older(repo, delay = 1):
+    OLD_QUERY = """Any X,DAY(AA),DAY(NOW) GROUPBY X,AA WHERE X is ExecutionTarget, X modification_date AA, X in_state ST, ST name "assigned" HAVING DAY(AA) != DAY(NOW)"""
+    # XXX make a proper one
+    session = repo.internal_session(safe=True)
+    try:
+        rset = session.execute(OLD_QUERY)
+        for old in rset.entities():
+            iwf = old.cw_adapt_to('IWorkflowable')
+            iwf.fire_transition('cancel')
+            session.commit(free_cnxset=False)
+    finally:
+        session.close()
+
 
 class ServerInitHook(hook.Hook):