summaryrefslogtreecommitdiffstats
path: root/stator/runner.py
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-09 23:48:31 -0700
committerAndrew Godwin2022-11-09 23:48:31 -0700
commit2c3a1299709f2612e96c37e4e121c83ad4df7a56 (patch)
tree89c2aed22a7a10730e02c809f83b744a21e295e1 /stator/runner.py
parent7746abbbb7700fa918450101bbc6d29ed9b4b608 (diff)
downloadtakahe-2c3a1299709f2612e96c37e4e121c83ad4df7a56.tar.gz
takahe-2c3a1299709f2612e96c37e4e121c83ad4df7a56.tar.bz2
takahe-2c3a1299709f2612e96c37e4e121c83ad4df7a56.zip
Profile fetching now working on state machine
Diffstat (limited to 'stator/runner.py')
-rw-r--r--stator/runner.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/stator/runner.py b/stator/runner.py
index f9c726e..1392e4d 100644
--- a/stator/runner.py
+++ b/stator/runner.py
@@ -1,6 +1,7 @@
import asyncio
import datetime
import time
+import traceback
import uuid
from typing import List, Type
@@ -53,7 +54,7 @@ class StatorRunner:
f"Attempting transition on {instance._meta.label_lower}#{instance.pk}"
)
self.tasks.append(
- asyncio.create_task(instance.atransition_attempt())
+ asyncio.create_task(self.run_transition(instance))
)
self.handled += 1
space_remaining -= 1
@@ -70,5 +71,17 @@ class StatorRunner:
print("Complete")
return self.handled
+ async def run_transition(self, instance: StatorModel):
+ """
+ Wrapper for atransition_attempt with fallback error handling
+ """
+ try:
+ await instance.atransition_attempt()
+ except BaseException:
+ traceback.print_exc()
+
def remove_completed_tasks(self):
+ """
+ Removes all completed asyncio.Tasks from our local in-progress list
+ """
self.tasks = [t for t in self.tasks if not t.done()]