diff options
author | Andrew Godwin | 2022-11-20 12:32:49 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-11-20 12:32:49 -0700 |
commit | f491fdb56e2de9200e14b855b5576009ca99dfa5 (patch) | |
tree | 5389fa8e3fef60ba1c7284087eba0d5616d222b3 /stator | |
parent | 77643a4fe144cb908a372a2ceb99f36634457ca5 (diff) | |
download | takahe-f491fdb56e2de9200e14b855b5576009ca99dfa5.tar.gz takahe-f491fdb56e2de9200e14b855b5576009ca99dfa5.tar.bz2 takahe-f491fdb56e2de9200e14b855b5576009ca99dfa5.zip |
Actor delete, sentry async, faster stator
Diffstat (limited to 'stator')
-rw-r--r-- | stator/models.py | 2 | ||||
-rw-r--r-- | stator/runner.py | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/stator/models.py b/stator/models.py index a84f8c2..426803a 100644 --- a/stator/models.py +++ b/stator/models.py @@ -158,7 +158,7 @@ class StatorModel(models.Model): if settings.SENTRY_ENABLED: from sentry_sdk import capture_exception - capture_exception(e) + await sync_to_async(capture_exception, thread_sensitive=False)(e) traceback.print_exc() else: if next_state: diff --git a/stator/runner.py b/stator/runner.py index ed459be..7daf921 100644 --- a/stator/runner.py +++ b/stator/runner.py @@ -5,6 +5,7 @@ import traceback import uuid from typing import List, Optional, Type +from asgiref.sync import sync_to_async from django.conf import settings from django.utils import timezone @@ -46,12 +47,12 @@ class StatorRunner: if (time.monotonic() - self.last_clean) >= self.schedule_interval: print(f"{self.handled} tasks processed so far") print("Running cleaning and scheduling") - self.remove_completed_tasks() for model in self.models: asyncio.create_task(model.atransition_clean_locks()) asyncio.create_task(model.atransition_schedule_due()) self.last_clean = time.monotonic() # Calculate space left for tasks + self.remove_completed_tasks() space_remaining = self.concurrency - len(self.tasks) # Fetch new tasks for model in self.models: @@ -95,7 +96,7 @@ class StatorRunner: if settings.SENTRY_ENABLED: from sentry_sdk import capture_exception - capture_exception(e) + await sync_to_async(capture_exception, thread_sensitive=False)(e) traceback.print_exc() def remove_completed_tasks(self): |