Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#87 0 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
testing-qa

Línea de trabajo

Empieza rastreando los hooks pytest_sessionfinish y pytest_testnodedown descritos en el issue, junto con el manejo de --forked por parte de pytest-forked y el archivo newhooks.py mencionado. Reproduce el problema con las versiones indicadas de Python, pytest, pytest-xdist y pytest-forked. Se considera terminado cuando las estadísticas de los workers están disponibles para el master durante pytest_testnodedown al habilitar --forked.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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)
Lenguaje dominante
Python
Estrellas
83
Forks
29
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pytest-dev/pytest-forked

Todos los issues de pytest-dev/pytest-forked

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.