Skip to content

Commit 7e95c5e

Browse files
authored
chore(tests): fix joblib cache race in eip2537 BLS precompile tests (#3174)
1 parent 87aba1a commit 7e95c5e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • tests/prague/eip2537_bls_12_381_precompiles

tests/prague/eip2537_bls_12_381_precompiles/helpers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,14 @@ class BLSPointGenerator:
167167
# G2 cofactor h₂: (x⁸ - 4x⁷ + 5x⁶ - 4x⁴ + 6x³ - 4x² - 4x + 13)/9
168168
G2_COFACTOR = 0x5D543A95414E7F1091D50792876A202CD91DE4547085ABAA68A205B2E5A7DDFA628F1CB4D9E82EF21537E293A6691AE1616EC6E786F0C70CF1C38E31C7238E5 # noqa: E501
169169

170-
# Memory cache for expensive functions
171-
memory = Memory(location=".cache", verbose=0)
170+
# Memory cache for expensive functions. Give each xdist worker its own
171+
# cache dir: joblib's disk cache races on concurrent writes, and these
172+
# functions run at collection time in every worker.
173+
_xdist_worker = os.environ.get("PYTEST_XDIST_WORKER", "")
174+
_cache_location = (
175+
f".cache/joblib-{_xdist_worker}" if _xdist_worker else ".cache"
176+
)
177+
memory = Memory(location=_cache_location, verbose=0)
172178

173179
@staticmethod
174180
def is_on_curve_g1(x: int, y: int) -> bool:

0 commit comments

Comments
 (0)