File: test_chaos.py

package info (click to toggle)
dask.distributed 2022.12.1%2Bds.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,164 kB
  • sloc: python: 81,938; javascript: 1,549; makefile: 228; sh: 100
file content (29 lines) | stat: -rw-r--r-- 657 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from __future__ import annotations

import asyncio

import pytest

from distributed import Nanny
from distributed.chaos import KillWorker
from distributed.utils_test import WINDOWS, gen_cluster


@pytest.mark.parametrize(
    "mode",
    [
        "sys.exit",
        "graceful",
        pytest.param("segfault", marks=pytest.mark.skipif(WINDOWS, reason="unknown")),
    ],
)
@gen_cluster(nthreads=[("127.0.0.1", 1)], client=True, Worker=Nanny)
async def test_KillWorker(c, s, w, mode):
    plugin = KillWorker(delay="1ms", mode=mode)

    await c.register_worker_plugin(plugin)

    while s.workers:
        await asyncio.sleep(0.001)

    await w.close()