Skip to content

Commit

Permalink
need to handle kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Nov 28, 2023
1 parent ed3a0cf commit 53ced31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions pioreactor/background_jobs/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,7 @@ def run_job_on_machine(self, msg: MQTTMessage) -> None:
options["experiment"] = whoami._get_latest_experiment_name() # techdebt
Thread(
target=utils.boolean_retry,
args=(led_intensity, (state,)),
kwargs=options,
args=(led_intensity, (state, options)),
).start()

elif job_name in (
Expand Down
8 changes: 6 additions & 2 deletions pioreactor/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@


def boolean_retry(
func: Callable[..., bool], f_args: tuple, max_attempts: int = 3, sleep_for: float = 0.25
func: Callable[..., bool],
f_args: tuple,
f_kwargs: dict,
max_attempts: int = 4,
sleep_for: float = 0.25,
) -> bool:
for _ in range(max_attempts):
res = func(*f_args)
res = func(*f_args, **f_kwargs)
if res:
return res
time.sleep(sleep_for)
Expand Down

0 comments on commit 53ced31

Please sign in to comment.