bpo-32253: Deprecate with statement and bare await for asyncio locks#4764
bpo-32253: Deprecate with statement and bare await for asyncio locks#4764asvetlov merged 10 commits intopython:masterfrom
Conversation
|
|
||
| This class is :ref:`not thread safe <asyncio-multithreading>`. | ||
|
|
||
| Usage:: |
There was a problem hiding this comment.
Let's have one usage example with 'async with ...' syntax.
There was a problem hiding this comment.
Never mind, I see that you added a new section for that...
Doc/library/asyncio-sync.rst
Outdated
| ------------------------------------------------------------------------------ | ||
|
|
||
| All of the objects provided by this module that have :meth:`acquire` | ||
| and :meth:`release` methods can be used as context managers for a |
There was a problem hiding this comment.
"can be used as context managers for a" -> "can be used in "async with" statements"
Doc/library/asyncio-sync.rst
Outdated
|
|
||
| Currently, :class:`Lock`, :class:`Condition`, | ||
| :class:`Semaphore`, and :class:`BoundedSemaphore` objects may be used as | ||
| :keyword:`async with` statement context managers. |
There was a problem hiding this comment.
This is a bit repetitive... I'd merge this paragraph with the first one:
":class:Lock, :class:Condition, :class:Semaphore, and :class:BoundedSemaphore can be used in "async with" statements."
Doc/library/asyncio-sync.rst
Outdated
| synchronization primitives. | ||
|
|
||
| Explicit :meth:`acquire` / :meth:`release` calls should be used if | ||
| locking/unlocking is split into different functions. |
There was a problem hiding this comment.
I don't think we need these two paragraphs. People usually naturally prefer 'with' blocks when they are available.
Doc/library/asyncio-sync.rst
Outdated
|
|
||
| .. deprecated:: 3.7 | ||
|
|
||
| Lock acquiring on ``await lock`` or ``yield from lock`` and |
There was a problem hiding this comment.
"Lock acquiring on" -> "Lock acquiring using"
|
All notes are fixed |
Doc/library/asyncio-sync.rst
Outdated
| defaults to ``1``. If the value given is less than ``0``, :exc:`ValueError` | ||
| is raised. | ||
|
|
||
| Locks also support the :ref:`context management protocol <async-with-locks>`. |
Doc/library/asyncio-sync.rst
Outdated
| This raises :exc:`ValueError` in :meth:`~Semaphore.release` if it would | ||
| increase the value above the initial value. | ||
|
|
||
| Locks also support the :ref:`context management protocol <async-with-locks>`. |
|
Spotted a few more nits; other than that it looks good |
|
Fixed |
Doc/library/asyncio-sync.rst
Outdated
| a new :class:`Lock` object is created and used as the underlying lock. | ||
|
|
||
| Locks also support the :ref:`context management protocol <async-with-locks>`. | ||
| Conditions also support the :ref:`context management protocol |
https://bugs.python.org/issue32253