Update docs for Handle, add Timer.
This commit is contained in:
parent
a1fb8fd657
commit
455dd3f556
29
pep-3156.txt
29
pep-3156.txt
|
@ -770,8 +770,13 @@ cancel the callback. For want of a better name this object is called
|
||||||
a ``Handle``, although the user never needs to instantiate
|
a ``Handle``, although the user never needs to instantiate
|
||||||
instances of this class. There is one public method:
|
instances of this class. There is one public method:
|
||||||
|
|
||||||
- ``cancel()``. Attempt to cancel the callback.
|
- ``cancel()``. Cancel the callback. This just sets the
|
||||||
TBD: Exact specification.
|
``cancelled`` attribute. The event loop must check this.
|
||||||
|
|
||||||
|
- ``run()``. Call the callback with the specified arguments. If this
|
||||||
|
raises an exception, it is logged and the function returns normally.
|
||||||
|
This always returns None. Note that this ignores the ``cancelled``
|
||||||
|
attribute (i.e., a cancelled ``Handle`` can still be called).
|
||||||
|
|
||||||
Read-only public attributes:
|
Read-only public attributes:
|
||||||
|
|
||||||
|
@ -783,15 +788,21 @@ Read-only public attributes:
|
||||||
|
|
||||||
Note that some callbacks (e.g. those registered with ``call_later()``)
|
Note that some callbacks (e.g. those registered with ``call_later()``)
|
||||||
are meant to be called only once. Others (e.g. those registered with
|
are meant to be called only once. Others (e.g. those registered with
|
||||||
``add_reader()``) are meant to be called multiple times.
|
``call_repeatedly()`` or ``add_reader()``) are meant to be called
|
||||||
|
multiple times.
|
||||||
|
|
||||||
TBD: An API to call the callback (encapsulating the exception handling
|
The Timer Subclass
|
||||||
necessary)? Should it record how many times it has been called?
|
''''''''''''''''''
|
||||||
Maybe this API should just be ``__call__()``? (But it should suppress
|
|
||||||
exceptions.)
|
|
||||||
|
|
||||||
TBD: Public attribute recording the realtime value when the callback
|
``Timer`` is a subclass of ``Handle`` returned by ``call_later()`` and
|
||||||
is scheduled? (Since this is needed anyway for storing it in a heap.)
|
``call_repeatedly()``.
|
||||||
|
|
||||||
|
It has one additional read-only public attribute:
|
||||||
|
|
||||||
|
- ``when``, the real time when the callback is next scheduled to be
|
||||||
|
called.
|
||||||
|
|
||||||
|
``Timer`` objects are ordered by their ``when`` field.
|
||||||
|
|
||||||
Futures
|
Futures
|
||||||
-------
|
-------
|
||||||
|
|
Loading…
Reference in New Issue