Rework if statement to reduce indentation, add comment about logic

guilles_counter_review
Guillermo Rodriguez 2025-02-03 18:58:55 -03:00
parent 4d56bb45e5
commit b62cdd6802
No known key found for this signature in database
GPG Key ID: 002CC5F1E6BDA53E
1 changed files with 83 additions and 86 deletions

View File

@ -177,11 +177,13 @@ class WorkerDaemon:
return False return False
results = [res['id'] for res in self._snap['results']] results = [res['id'] for res in self._snap['results']]
if (
rid not in results # if worker is already on that request or
and # if worker has a stale status for that request
rid in self._snap['requests'] if rid in results or rid not in self._snap['requests']:
): logging.info(f'request {rid} already beign worked on, skip...')
return
statuses = self._snap['requests'][rid] statuses = self._snap['requests'][rid]
if len(statuses) == 0: if len(statuses) == 0:
inputs = [] inputs = []
@ -261,11 +263,6 @@ class WorkerDaemon:
finally: finally:
return True return True
# TODO, i would inverse this case logic to avoid an indent
# level in above block ;)
else:
logging.info(f'request {rid} already beign worked on, skip...')
# TODO, as per above on `.maybe_serve_one()`, it's likely a bit # TODO, as per above on `.maybe_serve_one()`, it's likely a bit
# more *trionic* to define this all as a module level task-func # more *trionic* to define this all as a module level task-func
# which operates on a `daemon: WorkerDaemon`? # which operates on a `daemon: WorkerDaemon`?