chore: merge nolock.py and gil_enabled.py to gil.py

This commit is contained in:
rus07tam 2025-11-23 11:01:28 +00:00
parent 7b34426c82
commit 498087befb
3 changed files with 16 additions and 21 deletions

View file

@ -3,7 +3,7 @@ from .calls import call, caller
from .exceptions import catch, throw
from .frames import frame
from .inherit import inherit
from .nolock import nolock
from .gil import GIL_ENABLED, nolock
from .side import side, side_func
from .this import this
from .to_async import to_async
@ -13,6 +13,7 @@ __all__ = [
"caller",
"get_or_set_attr",
"get_attrs",
"GIL_ENABLED",
"frame",
"inherit",
"nolock",

View file

@ -4,6 +4,9 @@ if TYPE_CHECKING:
GIL_ENABLED: Final[bool] = bool(...)
"""
Whether the GIL is enabled."""
def nolock() -> None: ...
else:
import sys
@ -12,3 +15,14 @@ else:
GIL_ENABLED = sys._is_gil_enabled()
else:
GIL_ENABLED = True
if GIL_ENABLED:
import time
def nolock() -> None:
time.sleep(0.001)
else:
def nolock() -> None:
pass

View file

@ -1,20 +0,0 @@
from typing import TYPE_CHECKING
from .gil_enabled import GIL_ENABLED
if TYPE_CHECKING:
def nolock() -> None: ...
else:
if GIL_ENABLED:
import time
def nolock() -> None:
time.sleep(0.001)
else:
def nolock() -> None:
pass