graph LR
Worker_Main_Loop["Worker Main Loop"]
Test_Executor["Test Executor"]
Event_Reporter["Event Reporter"]
Command_Handler["Command Handler"]
Work_Stealing_Logic["Work Stealing Logic"]
Worker_Task_Queue["Worker Task Queue"]
Worker_Main_Loop -- "retrieves from" --> Worker_Task_Queue
Worker_Main_Loop -- "calls" --> Test_Executor
Worker_Main_Loop -- "invokes" --> Command_Handler
Test_Executor -- "reports outcome via" --> Event_Reporter
Command_Handler -- "adds to" --> Worker_Task_Queue
Command_Handler -- "delegates to" --> Work_Stealing_Logic
Work_Stealing_Logic -- "communicates via" --> Event_Reporter
Command_Handler -- "returns control to" --> Worker_Main_Loop
The pytest-xdist worker subsystem is designed to execute tests in a distributed environment, acting as a remote agent that receives commands, runs tests, and reports results back to a central coordinator. Its core functionality revolves around a main loop that continuously fetches tasks from an internal queue, processes them, and communicates test outcomes and status updates. The subsystem also incorporates logic for handling various commands from the coordinator, including work-stealing requests, to ensure efficient workload distribution and resource utilization across the distributed test setup.
Acts as the central orchestrator for the worker process. It manages the continuous execution loop, fetching commands or test items and dispatching them for processing.
Related Classes/Methods:
Executes a single test item assigned to the worker. It encapsulates the logic for running the test and capturing its outcome.
Related Classes/Methods:
Serves as the primary communication mechanism for the worker to send various events, test reports, and status updates back to the coordinator (master process).
Related Classes/Methods:
Interprets and executes specific control commands received from the coordinator. These commands can include instructions to add test items, initiate work-stealing, or other operational directives.
Related Classes/Methods:
Implements the work-stealing mechanism, allowing an idle worker to request and acquire test items from other busy workers. This optimizes resource utilization and balances the workload across the distributed test environment.
Related Classes/Methods:
An internal data structure (likely a queue) used for buffering and managing incoming commands and test items within the worker process. It decouples the reception of messages from their immediate processing, ensuring smooth operation.
Related Classes/Methods: