From eac59bde831064641fe5f27daa320011836b5353 Mon Sep 17 00:00:00 2001 From: Zeid Date: Thu, 30 Jan 2025 15:43:04 -0500 Subject: [PATCH] commands: remove unused WorkerMixin (bug 1927139) --- .../main/management/commands/__init__.py | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/src/lando/main/management/commands/__init__.py b/src/lando/main/management/commands/__init__.py index 319ad4dc..e69de29b 100644 --- a/src/lando/main/management/commands/__init__.py +++ b/src/lando/main/management/commands/__init__.py @@ -1,37 +0,0 @@ -from time import sleep - -from lando.main.models.worker import Worker - - -class WorkerMixin: - @property - def _instance(self) -> Worker: - return Worker.objects.get(name=self.name) - - def _start(self, max_loops: int | None = None, *args, **kwargs): - """Run the main event loop.""" - # NOTE: The worker will exit when max_loops is reached, or when the stop - # variable is changed to True. - loops = 0 - while not self._instance.is_stopped: - if max_loops is not None and loops >= max_loops: - break - while self._instance.is_paused: - self.throttle(self._instance.sleep_seconds) - self.loop(*args, **kwargs) - loops += 1 - - self.stdout.write(f"{self} exited after {loops} loops.") - - def throttle(self, seconds: int | None = None): - """Sleep for a given number of seconds.""" - sleep(seconds if seconds is not None else self._instance.throttle_seconds) - - def start(self, max_loops: int | None = None): - """Run setup sequence and start the event loop.""" - if not self._instance.is_stopped: - self._start(max_loops=max_loops) - - def loop(self, *args, **kwargs): - """The main event loop.""" - raise NotImplementedError()