pep-567: More fixes (#505)
This commit is contained in:
parent
c1f434c437
commit
4a8143fc16
15
pep-0567.rst
15
pep-0567.rst
|
@ -78,16 +78,15 @@ is accessed via ``contextvars.get_context()`` function.
|
|||
Manipulation of the current ``Context`` is the responsibility of the
|
||||
task framework, e.g. asyncio.
|
||||
|
||||
A ``Context`` is conceptually a mapping, implemented using an
|
||||
immutable dictionary. The ``ContextVar.get()`` method does a
|
||||
A ``Context`` is conceptually a read-only mapping, implemented using
|
||||
an immutable dictionary. The ``ContextVar.get()`` method does a
|
||||
lookup in the current ``Context`` with ``self`` as a key, raising a
|
||||
``LookupError`` or returning a default value specified in
|
||||
the constructor.
|
||||
|
||||
The ``ContextVar.set(value)`` method clones the current ``Context``,
|
||||
assigns the ``value`` to it with ``self`` as a key, and sets the
|
||||
new ``Context`` as a new current. Because ``Context`` uses an
|
||||
immutable dictionary, cloning it is O(1).
|
||||
new ``Context`` as a new current.
|
||||
|
||||
|
||||
Specification
|
||||
|
@ -221,9 +220,9 @@ keyword-only argument, which defaults to the current context::
|
|||
# ... some time later
|
||||
context.run(callback, *args)
|
||||
|
||||
Tasks in asyncio need to maintain their own isolated context that
|
||||
they inherit from the point they were created at. ``asyncio.Task``
|
||||
is modified as follows::
|
||||
Tasks in asyncio need to maintain their own context that they inherit
|
||||
from the point they were created at. ``asyncio.Task`` is modified
|
||||
as follows::
|
||||
|
||||
class Task:
|
||||
def __init__(self, coro):
|
||||
|
@ -395,7 +394,7 @@ Summary of the New APIs
|
|||
parameter can be used to specify a custom context.
|
||||
|
||||
* ``asyncio.Task`` is modified internally to maintain its own
|
||||
isolated context.
|
||||
context.
|
||||
|
||||
|
||||
Backwards Compatibility
|
||||
|
|
Loading…
Reference in New Issue