diff options
| author | Munyoki Kilyungi | 2025-04-22 19:38:25 +0300 |
|---|---|---|
| committer | BonfaceKilz | 2025-04-22 19:47:14 +0300 |
| commit | fd5bde91f0c4f72d355fed338af6c1a60a43bdcc (patch) | |
| tree | 2ec2bfe4d8a993141c394041c950981856c9ed8b | |
| parent | 7a318d457ab11056fcb463008deb256edc6cb4d7 (diff) | |
| download | genenetwork3-fd5bde91f0c4f72d355fed338af6c1a60a43bdcc.tar.gz | |
Autopep-8 file.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
| -rw-r--r-- | sheepdog/worker.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sheepdog/worker.py b/sheepdog/worker.py index 4c79f18..c4571e1 100644 --- a/sheepdog/worker.py +++ b/sheepdog/worker.py @@ -10,24 +10,27 @@ import redis.connection # Enable importing from one dir up: put as first to override any other globally # accessible GN3 -sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.insert(0, os.path.abspath( + os.path.join(os.path.dirname(__file__), '..'))) logging.basicConfig( format=("%(asctime)s — %(filename)s:%(lineno)s — %(levelname)s: " "CommandWorker: %(message)s")) logger = logging.getLogger(__name__) + def update_status(conn, cmd_id, status): """Helper to update command status""" conn.hset(name=f"{cmd_id}", key="status", value=f"{status}") -def make_incremental_backoff(init_val: float=0.1, maximum: int=420): + +def make_incremental_backoff(init_val: float = 0.1, maximum: int = 420): """ Returns a closure that can be used to increment the returned value up to `maximum` or reset it to `init_val`. """ current = init_val - def __increment_or_reset__(command: str, value: float=0.1): + def __increment_or_reset__(command: str, value: float = 0.1): nonlocal current if command == "reset": current = init_val @@ -41,6 +44,7 @@ def make_incremental_backoff(init_val: float=0.1, maximum: int=420): return __increment_or_reset__ + def run_jobs(conn, queue_name): """Process the redis using a redis connection, CONN""" # pylint: disable=E0401, C0415 @@ -62,6 +66,7 @@ def run_jobs(conn, queue_name): return cmd_id return None + def parse_cli_arguments(): """Parse the command-line arguments.""" parser = argparse.ArgumentParser( @@ -80,6 +85,7 @@ def parse_cli_arguments(): help="What level to output the logs at.") return parser.parse_args() + if __name__ == "__main__": args = parse_cli_arguments() logger.setLevel(args.log_level.upper()) @@ -97,6 +103,7 @@ if __name__ == "__main__": logger.debug("Ran a job. Pausing for a while...") time.sleep(sleep_time("reset")) continue - time.sleep(sleep_time("increment", sleep_time("return_current"))) + time.sleep(sleep_time( + "increment", sleep_time("return_current"))) logger.info("Worker exiting …") |
