Skip to content

Commit 3e95a05

Browse files
committed
Raise Empty when request_queue is None (#18111)
Co-authored-by: awaelchli <[email protected]> (cherry picked from commit 2b854a8)
1 parent 41320d8 commit 3e95a05

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/lightning/app/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
1313

1414
#### Fixed
1515

16-
-
16+
- Fixed handling a `None` request in the file orchestration queue ([#18111](https://github.com/Lightning-AI/lightning/pull/18111))
1717

1818

1919

src/lightning/app/storage/orchestrator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ def run_once(self, work_name: str) -> None:
106106
request_queue = self.request_queues[work_name]
107107
try:
108108
request: _PathRequest = request_queue.get(timeout=0) # this should not block
109+
# This should not happen under normal conditions, but it has occurred.
110+
# For now we are tolerant with respect to requests being None in the queue
111+
# and just move on.
112+
if request is None:
113+
raise Empty
109114
except Empty:
110115
pass
111116
else:

tests/tests_app/storage/test_orchestrator.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ def test_orchestrator():
4747
orchestrator.run_once("work_a")
4848
orchestrator.run_once("work_b")
4949

50+
# edge case: `None` requests on the queue get ignored
51+
# TODO: Investigate how `None` values end up in the queue
52+
request_queues["work_a"].put(None)
53+
orchestrator.run_once("work_a")
54+
orchestrator.run_once("work_b")
55+
assert not request_queues["work_a"]._queue
56+
5057
# simulate copier A confirms that the file is available on the shared volume
5158
response = _GetResponse(source="work_a", path="/a/b/c.txt", hash="", destination="work_b", name="")
5259
copy_request_queues["work_a"].get()

0 commit comments

Comments
 (0)