Skip to content

Commit a746675

Browse files
committed
feat: avoid concurrent wrapper builds
1 parent 454c369 commit a746675

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ classifiers = [
3737
dependencies = [
3838
"cffi ~= 1.15.1",
3939
"pytest>=3.8",
40+
"filelock ~= 3.12.2",
4041
"setuptools ~= 67.8.0; python_full_version >= '3.12.0b1'", # FIXME: remove when cffi supports directly python 3.12
4142
]
4243

src/pytest_codspeed/_wrapper/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import TYPE_CHECKING
33

44
from cffi import FFI # type: ignore
5+
from filelock import FileLock
56

67
if TYPE_CHECKING:
78
from .wrapper import lib as LibType
@@ -24,10 +25,12 @@ def _get_ffi():
2425
def get_lib() -> "LibType":
2526
try:
2627
ffi = _get_ffi()
27-
ffi.compile(
28-
target="dist_callgrind_wrapper.*",
29-
tmpdir=_wrapper_dir,
30-
)
28+
build_lock = FileLock(f"{_wrapper_dir}/build.lock")
29+
with build_lock:
30+
ffi.compile(
31+
target="dist_callgrind_wrapper.*",
32+
tmpdir=_wrapper_dir,
33+
)
3134
from .dist_callgrind_wrapper import lib # type: ignore
3235

3336
return lib

0 commit comments

Comments
 (0)