超时
Utilities for performing local, signal-based timeouts. Implementation from https://github.com/glenfant/stopit under the MIT license.
from prairielearn.timeout_utils import ...
SignalTimeout ¶
Context manager for limiting the execution time of a block.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
seconds
|
float | int
|
duration to run the context manager block |
必需 |
swallow_exc
|
bool
|
|
True
|
__exit__ ¶
__exit__(
exc_type: type[BaseException] | None,
exc_value: BaseException | None,
traceback: TracebackType | None,
) -> bool
Manages exceptions & timeout.
ThreadingTimeout ¶
Deprecated alias for SignalTimeout.
TimeoutExceptionError ¶
Raised when the block under context management takes longer to complete than the allowed maximum timeout value.