Skip to content

Commit 1369269

Browse files
committed
assert instead
1 parent 68c91ed commit 1369269

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

sky/server/requests/requests.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from sky.server.requests.serializers import encoders
3636
from sky.utils import asyncio_utils
3737
from sky.utils import common_utils
38+
from sky.utils import env_options
3839
from sky.utils import ux_utils
3940
from sky.utils.db import db_utils
4041

@@ -669,10 +670,13 @@ async def kill_request_async(request_id: str) -> bool:
669670
@metrics_lib.time_me
670671
def update_request(request_id: str) -> Generator[Optional[Request], None, None]:
671672
"""Get and update a SkyPilot API request."""
673+
# In developer mode, we assert if synchronous filelock is
674+
# being used in an async context.
675+
if (env_options.Options.IS_DEVELOPER.get() and not _is_running_pytest() and
676+
asyncio_utils.is_running_async()):
677+
assert False, 'synchronous filelock is being used in an async context'
672678
# Acquire the lock to avoid race conditions between multiple request
673679
# operations, e.g. execute and cancel.
674-
if not _is_running_pytest() and asyncio_utils.is_running_async():
675-
logger.warning('synchronous filelock is being used in an async context')
676680
with filelock.FileLock(request_lock_path(request_id)):
677681
request = _get_request_no_lock(request_id)
678682
yield request
@@ -759,8 +763,11 @@ async def get_latest_request_id_async() -> Optional[str]:
759763
def get_request(request_id: str,
760764
fields: Optional[List[str]] = None) -> Optional[Request]:
761765
"""Get a SkyPilot API request."""
762-
if not _is_running_pytest() and asyncio_utils.is_running_async():
763-
logger.warning('synchronous filelock is being used in an async context')
766+
# In developer mode, we assert if synchronous filelock is
767+
# being used in an async context.
768+
if (env_options.Options.IS_DEVELOPER.get() and not _is_running_pytest() and
769+
asyncio_utils.is_running_async()):
770+
assert False, 'synchronous filelock is being used in an async context'
764771
with filelock.FileLock(request_lock_path(request_id)):
765772
return _get_request_no_lock(request_id, fields)
766773

0 commit comments

Comments
 (0)