mirror of https://github.com/skygpu/skynet.git
Rework if statement to reduce indentation, add comment about logic
parent
4d56bb45e5
commit
b62cdd6802
|
@ -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`?
|
||||||
|
|
Loading…
Reference in New Issue