Bases: builtins.BaseException
Raise exception in the current greenthread after timeout seconds.
When exception is omitted or None, the Timeout instance itself is raised. If
seconds is None, the timer is not scheduled, and is only useful if you’re planning to raise it
directly.
Timeout objects are context managers, and so can be used in with statements. When used in a with
statement, if exception is False, the timeout is still raised, but the context manager
suppresses it, so the code outside the with-block won’t see it.
-
pending[source]
@property
True if the timeout is scheduled to be raised
-
__init__(seconds=None, exception=None)[source]
Parameters: |
- seconds (float) – timeout seconds
- exception – exception to raise when timeout occurs
|
-
cancel() → None[source]
If the timeout is pending, cancel it
If not using Timeouts in with statements, always call cancel() in a finally after
the block of code that is getting timed out. If not canceled, the timeout will be raised
later on, in some unexpected section of the application.
-
start() → None[source]
Schedule the timeout. This is called on construction, so
it should not be called explicitly, unless the timer has been
canceled.