Cancel shutdown when crashed worker is restarted (#813)

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
Aleksandr Mezin
2022-09-07 02:37:38 +06:00
committed by GitHub
parent 6169d494a4
commit e407a3377e
3 changed files with 27 additions and 0 deletions

1
changelog/813.bugfix Normal file
View File

@@ -0,0 +1 @@
Cancel shutdown when a crashed worker is restarted.

View File

@@ -225,6 +225,7 @@ class DSession:
self.triggershutdown() self.triggershutdown()
else: else:
self.report_line("\nreplacing crashed worker %s" % node.gateway.id) self.report_line("\nreplacing crashed worker %s" % node.gateway.id)
self.shuttingdown = False
self._clone_node(node) self._clone_node(node)
self._active_nodes.remove(node) self._active_nodes.remove(node)

View File

@@ -94,3 +94,28 @@ class TestCrashItem:
res = pytester.runpytest("-n2", "-s") res = pytester.runpytest("-n2", "-s")
res.stdout.fnmatch_lines_random(["*HOOK: pytest_handlecrashitem"]) res.stdout.fnmatch_lines_random(["*HOOK: pytest_handlecrashitem"])
res.stdout.fnmatch_lines(["*3 passed*"]) res.stdout.fnmatch_lines(["*3 passed*"])
def test_handlecrashitem_one(self, pytester: pytest.Pytester) -> None:
"""Test pytest_handlecrashitem hook with just one test."""
pytester.makeconftest(
"""
test_runs = 0
def pytest_handlecrashitem(crashitem, report, sched):
global test_runs
if test_runs == 0:
sched.mark_test_pending(crashitem)
test_runs = 1
else:
print("HOOK: pytest_handlecrashitem")
"""
)
res = pytester.runpytest("-n1", "-s", "-k", "test_b")
res.stdout.fnmatch_lines_random(["*HOOK: pytest_handlecrashitem"])
res.stdout.fnmatch_lines(
[
"FAILED test_handlecrashitem_one.py::test_b",
"FAILED test_handlecrashitem_one.py::test_b",
]
)