This commit is contained in:
@@ -9,10 +9,32 @@ Generic utilities.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import errno
|
||||
import sys
|
||||
|
||||
from contextlib import suppress
|
||||
from typing import Any
|
||||
from typing import Any, Callable
|
||||
|
||||
|
||||
def until_not_interrupted(f: Callable[..., Any], *args: Any, **kw: Any) -> Any:
|
||||
"""
|
||||
Retry until *f* succeeds or an exception that isn't caused by EINTR occurs.
|
||||
|
||||
Arguments:
|
||||
|
||||
f: A callable like a function.
|
||||
|
||||
*args: Positional arguments for *f*.
|
||||
|
||||
**kw: Keyword arguments for *f*.
|
||||
"""
|
||||
while True:
|
||||
try:
|
||||
return f(*args, **kw)
|
||||
except OSError as e: # noqa: PERF203
|
||||
if e.args[0] == errno.EINTR:
|
||||
continue
|
||||
raise
|
||||
|
||||
|
||||
def get_processname() -> str:
|
||||
|
||||
Reference in New Issue
Block a user