Skip to content

Commit e407a33

Browse files
amezinnicoddemus
andauthored
Cancel shutdown when crashed worker is restarted (#813)
Co-authored-by: Bruno Oliveira <[email protected]>
1 parent 6169d49 commit e407a33

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

changelog/813.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cancel shutdown when a crashed worker is restarted.

src/xdist/dsession.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def worker_errordown(self, node, error):
225225
self.triggershutdown()
226226
else:
227227
self.report_line("\nreplacing crashed worker %s" % node.gateway.id)
228+
self.shuttingdown = False
228229
self._clone_node(node)
229230
self._active_nodes.remove(node)
230231

testing/test_newhooks.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,28 @@ def pytest_handlecrashitem(crashitem, report, sched):
9494
res = pytester.runpytest("-n2", "-s")
9595
res.stdout.fnmatch_lines_random(["*HOOK: pytest_handlecrashitem"])
9696
res.stdout.fnmatch_lines(["*3 passed*"])
97+
98+
def test_handlecrashitem_one(self, pytester: pytest.Pytester) -> None:
99+
"""Test pytest_handlecrashitem hook with just one test."""
100+
pytester.makeconftest(
101+
"""
102+
test_runs = 0
103+
104+
def pytest_handlecrashitem(crashitem, report, sched):
105+
global test_runs
106+
107+
if test_runs == 0:
108+
sched.mark_test_pending(crashitem)
109+
test_runs = 1
110+
else:
111+
print("HOOK: pytest_handlecrashitem")
112+
"""
113+
)
114+
res = pytester.runpytest("-n1", "-s", "-k", "test_b")
115+
res.stdout.fnmatch_lines_random(["*HOOK: pytest_handlecrashitem"])
116+
res.stdout.fnmatch_lines(
117+
[
118+
"FAILED test_handlecrashitem_one.py::test_b",
119+
"FAILED test_handlecrashitem_one.py::test_b",
120+
]
121+
)

0 commit comments

Comments
 (0)