Skip to content

Commit

Permalink
refactor: Simplify and update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed Sep 20, 2024
1 parent f1899ae commit 542b33f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/ai/backend/manager/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,9 @@ async def retry_txn(max_attempts: int = 20) -> AsyncIterator[AttemptManager]:
stop=stop_after_attempt(max_attempts),
retry=retry_if_exception_type(TryAgain) | retry_if_exception_type(DBAPIError),
):
# The caller of a Python generator cannot catch the exceptions thrown in the block,
# so we need to pass AttemptManager.
# Since Python generators cannot catch the exceptions thrown in the code block executed
# when yielded because stack frames are switched, we should pass AttemptManager to
# provide a shared exception handling mechanism like the original execute_with_retry().
yield attempt
assert attempt.retry_state.outcome is not None
exc = attempt.retry_state.outcome.exception()
Expand Down
2 changes: 1 addition & 1 deletion src/ai/backend/manager/scheduler/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def prioritize(pending_sessions: Sequence[SessionRow]) -> tuple[int, list[Sessio
return -1, []
priorities = {s.priority for s in pending_sessions}
assert len(priorities) > 0
top_priority = sorted(priorities, reverse=True)[0]
top_priority = max(priorities)
return top_priority, [*filter(lambda s: s.priority == top_priority, pending_sessions)]

@abstractmethod
Expand Down

0 comments on commit 542b33f

Please sign in to comment.