Skip to content

Commit

Permalink
Positively initialize error value during scheduling and use a locally…
Browse files Browse the repository at this point in the history
…-significant variable name. #1363
  • Loading branch information
mfeit-internet2 committed Nov 3, 2023
1 parent 46c48cb commit 79a99c1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pscheduler-server/pscheduler-server/daemons/scheduler
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ def schedule_task(number, task, key, runs, trynext, anytime, json,
"""Do the actual work of scheduling a run."""
# TODO: This could probably be part of the SchedulerWorker class.

scheduling_error = None

log_debug("%d: %sTASK %s, %d runs, try %s", number,
"ANYTIME " if anytime else "",
task, runs, trynext)
Expand Down Expand Up @@ -780,11 +782,11 @@ def schedule_task(number, task, key, runs, trynext, anytime, json,
while tries_left > 0:
tries_left -= 1
try:
run_uri, start_time, end_time, skip, conflict, error \
run_uri, start_time, end_time, skip, conflict, scheduling_error \
= run_post(number, log_debug, url, trynext, anytime, lead_bind,
log=log, key=key)
except Exception as ex:
error = str(ex)
scheduling_error = str(ex)
skip = False
break

Expand All @@ -798,17 +800,16 @@ def schedule_task(number, task, key, runs, trynext, anytime, json,

if tries_left == 0:
skip = False
error = "Gave up after too many scheduling conflicts."
scheduling_error = "Gave up after too many scheduling conflicts."
# TODO: Delete lead run

if skip:
log_debug("%d: Skipping: %s", number, error)
log_debug("%d: Skipping: %s", number, scheduling_error)
return

if error is not None:
log_debug("%d: Unable: %s", number, error)
raise NonStarterException(error)

if scheduling_error is not None:
log_debug("%d: Unable: %s", number, scheduling_error)
raise NonStarterException(scheduling_error)

log_debug("%d: Scheduled for %s - %s at %s", number, start_time,
end_time, run_uri)
Expand Down

0 comments on commit 79a99c1

Please sign in to comment.