Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

xdist master cant see workers' workeroutput when using --forked

オープン
#87 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
testing-qa

調査の方向性

まず、issue に記載されている pytest_sessionfinish フックと pytest_testnodedown フックを、pytest-forked による --forked の処理および参照されている newhooks.py と併せて追跡します。記載されている Python、pytest、pytest-xdist、pytest-forked のバージョンで再現します。--forked が有効な場合に、pytest_testnodedown 中に worker の統計情報を master が利用できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Hi fellas.

I am building a tests profiler for collecting various statistics before/during test cases execution.
Since we use pytest-xdist, I decided its finally time to look into how new xdist hooks from newhooks.py work and try to get as much value out of them as possible, since doing shenanigans with locks and writing output to tmp files is pretty ugly.

I have finished my profiler MVP, and it was working nicely, until I tried to run it in our jenkins which uses --forked option.
setup
python-3.8.10
pytest-7.4.3
pytest-xdist-3.3.1
pytest-forked-1.6.0

ISSUE
Turned out no stats are being displayed when I use this option.
Inside pytest_testnodedown hook, where master node is collecting and aggregating collected statistics from all worker nodes, the node.workeroutput attribute is simply empty.

Is there some workaround for this, on how to properly send data from workers to master when using --forked? Am I just missing something?

Here are 2 most important hooks used for collecting and aggregating all the statistics.

    @pytest.hookimpl(hookwrapper=True, tryfirst=True)
    def pytest_sessionfinish(self):
        worker_id = get_xdist_worker_id(self)
        if worker_id != "master":
            # NOTE: Execnet can't serialize custom classes. Serialization has to be
            # implemented for everything we want to send in-between master and workers
            self.config.workeroutput[
                f"{worker_id}-stats"
            ] = self._profiling_stats.serialize()
        yield

    @pytest.hookimpl(trylast=True)
    def pytest_testnodedown(self, node):
        worker_id = node.workerinput["workerid"]
        node_stats = node.workeroutput[f"{worker_id}-stats"]
        node_stats = ProfilerNamespaceUnit.deserialize(node_stats)
        self._profiling_stats.merge_trees(node_stats)
主要言語
Python
スター
83
フォーク
29
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pytest-dev/pytest-forked のほかの issue

pytest-dev/pytest-forked の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。