|
35 | 35 | from sky.server.requests.serializers import encoders |
36 | 36 | from sky.utils import asyncio_utils |
37 | 37 | from sky.utils import common_utils |
| 38 | +from sky.utils import env_options |
38 | 39 | from sky.utils import ux_utils |
39 | 40 | from sky.utils.db import db_utils |
40 | 41 |
|
@@ -669,10 +670,13 @@ async def kill_request_async(request_id: str) -> bool: |
669 | 670 | @metrics_lib.time_me |
670 | 671 | def update_request(request_id: str) -> Generator[Optional[Request], None, None]: |
671 | 672 | """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' |
672 | 678 | # Acquire the lock to avoid race conditions between multiple request |
673 | 679 | # 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') |
676 | 680 | with filelock.FileLock(request_lock_path(request_id)): |
677 | 681 | request = _get_request_no_lock(request_id) |
678 | 682 | yield request |
@@ -759,8 +763,11 @@ async def get_latest_request_id_async() -> Optional[str]: |
759 | 763 | def get_request(request_id: str, |
760 | 764 | fields: Optional[List[str]] = None) -> Optional[Request]: |
761 | 765 | """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' |
764 | 771 | with filelock.FileLock(request_lock_path(request_id)): |
765 | 772 | return _get_request_no_lock(request_id, fields) |
766 | 773 |
|
|
0 commit comments