timeout: Rename to unsafe_timeout.

This timeout strategy using asynchronous exceptions has a number of
safety caveats (read the docstring!!) and should only be used in very
specific circumstances.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-04-18 10:44:46 -07:00
committed by Tim Abbott
parent 631c2f7d4c
commit 72018cc26b
5 changed files with 10 additions and 10 deletions

View File

@@ -22,7 +22,7 @@ class TimeoutExpiredError(Exception):
ResultT = TypeVar("ResultT")
def timeout(timeout: float, func: Callable[[], ResultT]) -> ResultT:
def unsafe_timeout(timeout: float, func: Callable[[], ResultT]) -> ResultT:
"""Call the function in a separate thread.
Return its return value, or raise an exception,
within approximately 'timeout' seconds.