Skip to content

Commit

Permalink
feat: avoid concurrent wrapper builds
Browse files Browse the repository at this point in the history
  • Loading branch information
art049 committed Sep 1, 2023
1 parent 5ea93c8 commit f3a6556
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ classifiers = [
dependencies = [
"cffi ~= 1.15.1",
"pytest>=3.8",
"filelock ~= 3.12.2",
"setuptools ~= 67.8.0; python_full_version >= '3.12.0b1'", # FIXME: remove when cffi supports directly python 3.12
]

Expand Down
11 changes: 7 additions & 4 deletions src/pytest_codspeed/_wrapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import TYPE_CHECKING

from cffi import FFI # type: ignore
from filelock import FileLock

if TYPE_CHECKING:
from .wrapper import lib as LibType
Expand All @@ -24,10 +25,12 @@ def _get_ffi():
def get_lib() -> "LibType":
try:
ffi = _get_ffi()
ffi.compile(
target="dist_callgrind_wrapper.*",
tmpdir=_wrapper_dir,
)
build_lock = FileLock(f"{_wrapper_dir}/build.lock")
with build_lock:
ffi.compile(
target="dist_callgrind_wrapper.*",
tmpdir=_wrapper_dir,
)
from .dist_callgrind_wrapper import lib # type: ignore

return lib
Expand Down

0 comments on commit f3a6556

Please sign in to comment.