Skip to content

Commit bd970cb

Browse files
rename "atomic" to "uninterruptible"
1 parent bf7b54d commit bd970cb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

rosys/automation/automation.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
from contextvars import ContextVar
88
from typing import Any
99

10-
# context for the currently running Automation; used by @atomic
10+
# context for the currently running Automation; used by @uninterruptible
1111
_CURRENT_AUTOMATION: ContextVar[Automation | None] = ContextVar('rosys_automation_current', default=None)
1212

1313

14-
def atomic(func: Callable):
14+
def uninterruptible(func: Callable):
1515
"""Decorator to make an async function uninterruptible until it exits."""
1616
@functools.wraps(func)
1717
async def _wrapped(*args, **kwargs):
1818
automation = _CURRENT_AUTOMATION.get()
1919
try:
2020
if automation is not None:
21-
automation._atomic_depth += 1
21+
automation._uninterruptible_depth += 1
2222
result = await func(*args, **kwargs)
2323
finally:
2424
if automation is not None:
25-
automation._atomic_depth -= 1
25+
automation._uninterruptible_depth -= 1
2626
await asyncio.sleep(0)
2727
return result
2828
return _wrapped
@@ -47,7 +47,7 @@ def __init__(self,
4747
self._can_run.set()
4848
self._stop = False
4949
self._is_waited = False
50-
self._atomic_depth = 0 # >0 while inside an @atomic section
50+
self._uninterruptible_depth = 0 # >0 while inside an @uninterruptible section
5151

5252
@property
5353
def is_running(self) -> bool:
@@ -72,14 +72,14 @@ def __await__(self) -> Generator[Any, None, Any | None]:
7272
iter_send, iter_throw = coro_iter.send, coro_iter.throw
7373
send: Callable = iter_send
7474
message: Any = None
75-
while not (self._atomic_depth == 0 and self._stop):
75+
while not (self._uninterruptible_depth == 0 and self._stop):
7676
try:
77-
while self._atomic_depth == 0 and not self._can_run.is_set() and not self._stop:
77+
while self._uninterruptible_depth == 0 and not self._can_run.is_set() and not self._stop:
7878
yield from self._can_run.wait().__await__() # pylint: disable=no-member
7979
except BaseException as err:
8080
send, message = iter_throw, err
8181

82-
if self._atomic_depth == 0 and self._stop:
82+
if self._uninterruptible_depth == 0 and self._stop:
8383
return None
8484

8585
try:

0 commit comments

Comments
 (0)