Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: treat certain API errors better; give more time for high queued MPS #27

Merged
merged 4 commits into from
Oct 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions horde_worker_regen/process_management/process_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,15 +1439,20 @@ async def api_submit_job(self) -> None:
async with self._completed_jobs_lock:
self.completed_jobs.remove(completed_job_info)
self._consecutive_failed_job_submits = 0

return

if "already submitted" in job_submit_response.message:
logger.debug(f"Job {job_info.id_} has already been submitted, removing from completed jobs")
async with self._completed_jobs_lock:
self.completed_jobs.remove(completed_job_info)
self._consecutive_failed_job_submits = 0
return

if "Please check your worker speed" in job_submit_response.message:
logger.error(job_submit_response.message)
async with self._completed_jobs_lock:
self.completed_jobs.remove(completed_job_info)
self._consecutive_failed_job_submits = 0
return

error_string = "Failed to submit job (API Error)"
Expand Down Expand Up @@ -1620,9 +1625,12 @@ async def api_job_pop(self) -> None:
# Assuming a megapixelstep takes 0.75 seconds, if 2/3 of the time has passed since the limit was triggered,
# we can assume that the pending megapixelsteps will be below the limit soon. Otherwise we continue to wait

if not (time.time() - self._triggered_max_pending_megapixelsteps_time) > (
(self._max_pending_megapixelsteps * 0.75) * (2 / 3)
):
seconds_to_wait = (self._max_pending_megapixelsteps * 0.75) * (2 / 3)

if self.get_pending_megapixelsteps() > 200:
seconds_to_wait = self._max_pending_megapixelsteps * 0.75

if not (time.time() - self._triggered_max_pending_megapixelsteps_time) > seconds_to_wait:
return

self._triggered_max_pending_megapixelsteps = False
Expand Down