Skip to content

[Serve] BugFix: LiveError on controller #4995

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

Merged
merged 4 commits into from
Mar 24, 2025
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
31 changes: 22 additions & 9 deletions sky/utils/rich_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,28 @@ def __enter__(self):
return _statuses[self.status_type]

def __exit__(self, exc_type, exc_val, exc_tb):
global _status_nesting_level
_status_nesting_level -= 1
if _status_nesting_level <= 0:
_status_nesting_level = 0
if _statuses[self.status_type] is not None:
_statuses[self.status_type].__exit__(exc_type, exc_val, exc_tb)
_statuses[self.status_type] = None
else:
_statuses[self.status_type].update(self.previous_message)
# We use the same lock with the `safe_logger` to avoid the following 2
# raice conditions. We refer loggers in another thread as "thread
# logger" hereafter.
# 1. When a thread logger stopped the status in `safe_logger`, and
# here we exit the status and set it to None. Then the thread logger
# will raise an error when it tries to restart the status.
# 2. When a thread logger stopped the status in `safe_logger`, and
# here we exit the status and entered a new one. Then the thread
# logger will raise an error when it tries to restart the old status,
# since only one LiveStatus can be started at the same time.
# Please refer to #4995 for more information.
with _logging_lock:
global _status_nesting_level
_status_nesting_level -= 1
if _status_nesting_level <= 0:
_status_nesting_level = 0
if _statuses[self.status_type] is not None:
_statuses[self.status_type].__exit__(
exc_type, exc_val, exc_tb)
_statuses[self.status_type] = None
else:
_statuses[self.status_type].update(self.previous_message)

def update(self, *args, **kwargs):
_statuses[self.status_type].update(*args, **kwargs)
Expand Down