|
16 | 16 |
|
17 | 17 | from distributed import Client, Nanny, Scheduler, Worker, config, default_client
|
18 | 18 | from distributed.compatibility import WINDOWS
|
19 |
| -from distributed.core import Server, rpc |
| 19 | +from distributed.core import Server, Status, rpc |
20 | 20 | from distributed.metrics import time
|
21 | 21 | from distributed.utils import mp_context
|
22 | 22 | from distributed.utils_test import (
|
23 | 23 | _LockedCommPool,
|
24 | 24 | _UnhashableCallable,
|
25 | 25 | assert_story,
|
| 26 | + captured_logger, |
26 | 27 | check_process_leak,
|
27 | 28 | cluster,
|
28 | 29 | dump_cluster_state,
|
@@ -731,15 +732,27 @@ def test_raises_with_cause():
|
731 | 732 | raise RuntimeError("exception") from ValueError("cause")
|
732 | 733 |
|
733 | 734 |
|
734 |
| -def test_worker_fail_hard(capsys): |
735 |
| - @gen_cluster(client=True, nthreads=[("127.0.0.1", 1)]) |
736 |
| - async def test_fail_hard(c, s, a): |
737 |
| - with pytest.raises(Exception): |
738 |
| - await a.gather_dep( |
739 |
| - worker="abcd", to_gather=["x"], total_nbytes=0, stimulus_id="foo" |
740 |
| - ) |
| 735 | +@gen_cluster(nthreads=[("", 1)]) |
| 736 | +async def test_fail_hard(s, a): |
| 737 | + with captured_logger("distributed.worker") as logger: |
| 738 | + # Asynchronously kick off handle_acquire_replicas on the worker, |
| 739 | + # which will fail |
| 740 | + s.stream_comms[a.address].send( |
| 741 | + { |
| 742 | + "op": "acquire-replicas", |
| 743 | + "who_has": {"x": ["abcd"]}, |
| 744 | + "stimulus_id": "foo", |
| 745 | + }, |
| 746 | + ) |
| 747 | + while a.status != Status.closed: |
| 748 | + await asyncio.sleep(0.01) |
| 749 | + |
| 750 | + assert "missing port number in address 'abcd'" in logger.getvalue() |
741 | 751 |
|
742 |
| - with pytest.raises(Exception) as info: |
743 |
| - test_fail_hard() |
744 | 752 |
|
745 |
| - assert "abcd" in str(info.value) |
| 753 | +@gen_cluster(nthreads=[("", 1)]) |
| 754 | +async def test_fail_hard_reraises(s, a): |
| 755 | + with pytest.raises(AttributeError): |
| 756 | + a.handle_stimulus(None) |
| 757 | + while a.status != Status.closed: |
| 758 | + await asyncio.sleep(0.01) |
0 commit comments