Skip to content

Commit 8d53030

Browse files
thomasbbrunnerionelmc
authored andcommitted
Fix identification of xdist
1 parent 3670df1 commit 8d53030

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pytest_benchmark/session.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
from functools import partial
7+
import os
78

89
import pytest
910

@@ -68,7 +69,9 @@ def __init__(self, config):
6869
self.skip = config.getoption('benchmark_skip')
6970
self.disabled = config.getoption('benchmark_disable') and not config.getoption('benchmark_enable')
7071

71-
if config.getoption('dist', 'no') != 'no' and not self.skip and not self.disabled:
72+
# Only the main process has the 'dist' field in the config.
73+
xdist_active = config.getoption('dist', 'no') != 'no' or os.environ.get('PYTEST_XDIST_WORKER', None)
74+
if xdist_active and not self.skip and not self.disabled:
7275
self.logger.warning(
7376
'Benchmarks are automatically disabled because xdist plugin is active.'
7477
'Benchmarks cannot be performed reliably in a parallelized environment.',

0 commit comments

Comments
 (0)