MCPcopy Create free account
hub / github.com/pytest-dev/pytest-xdist / remove_node

Method remove_node

src/xdist/scheduler/load.py:213–236  ·  view source on GitHub ↗

Remove a node from the scheduler. This should be called either when the node crashed or at shutdown time. In the former case any pending items assigned to the node will be re-scheduled. Called by the ``DSession.worker_workerfinished`` and ``DSession.worker_

(self, node: WorkerController)

Source from the content-addressed store, hash-verified

211 self.log("num items waiting for node:", len(self.pending))
212
213 def remove_node(self, node: WorkerController) -> str | None:
214 """Remove a node from the scheduler.
215
216 This should be called either when the node crashed or at
217 shutdown time. In the former case any pending items assigned
218 to the node will be re-scheduled. Called by the
219 ``DSession.worker_workerfinished`` and
220 ``DSession.worker_errordown`` hooks.
221
222 Return the item which was being executing while the node
223 crashed or None if the node has no more pending items.
224
225 """
226 pending = self.node2pending.pop(node)
227 if not pending:
228 return None
229
230 # The node crashed, reassing pending items
231 assert self.collection is not None
232 crashitem = self.collection[pending.pop(0)]
233 self.pending.extend(pending)
234 for node in self.node2pending:
235 self.check_schedule(node)
236 return crashitem
237
238 def schedule(self) -> None:
239 """Initiate distribution of the test collection.

Callers 1

test_add_remove_nodeMethod · 0.95

Calls 1

check_scheduleMethod · 0.95

Tested by 1

test_add_remove_nodeMethod · 0.76