Skip to content

Commit 467ffe1

Browse files
use Runner
1 parent 49f86a1 commit 467ffe1

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

Tools/jit/_llvm.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,12 @@ async def wrapper(
3232
return wrapper
3333

3434

35-
_CORES: asyncio.BoundedSemaphore | None = None
36-
37-
38-
def _get_cores() -> asyncio.BoundedSemaphore:
39-
global _CORES
40-
if _CORES is None:
41-
_CORES = asyncio.BoundedSemaphore(os.cpu_count() or 1)
42-
return _CORES
35+
_CORES = asyncio.BoundedSemaphore(os.cpu_count() or 1)
4336

4437

4538
async def _run(tool: str, args: typing.Iterable[str], echo: bool = False) -> str | None:
4639
command = [tool, *args]
47-
async with _get_cores():
40+
async with _CORES:
4841
if echo:
4942
print(shlex.join(command))
5043
try:

Tools/jit/_targets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
CPYTHON = TOOLS.parent
2626
PYTHON_EXECUTOR_CASES_C_H = CPYTHON / "Python" / "executor_cases.c.h"
2727
TOOLS_JIT_TEMPLATE_C = TOOLS_JIT / "template.c"
28+
ASYNCIO_RUNNER = asyncio.Runner()
2829

2930
_S = typing.TypeVar("_S", _schema.COFFSection, _schema.ELFSection, _schema.MachOSection)
3031
_R = typing.TypeVar(
@@ -199,7 +200,7 @@ def build(
199200
and jit_stencils.read_text().startswith(digest)
200201
):
201202
return
202-
stencil_groups = asyncio.run(self._build_stencils())
203+
stencil_groups = ASYNCIO_RUNNER.run(self._build_stencils())
203204
jit_stencils_new = out / "jit_stencils.h.new"
204205
try:
205206
with jit_stencils_new.open("w") as file:

0 commit comments

Comments
 (0)