Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
|
|
||
| This class is :ref:`not thread safe <asyncio-multithreading>`. | ||
|
|
||
| Usage:: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Let's have one usage example with 'async with ...' syntax.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Never mind, I see that you added a new section for that...
| ------------------------------------------------------------------------------ | ||
|
|
||
| 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.
The reason will be displayed to describe this comment to others. Learn more.
"can be used as context managers for a" -> "can be used in "async with" statements"
|
|
||
| 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.
The reason will be displayed to describe this comment to others. Learn more.
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."
| 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.
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need these two paragraphs. People usually naturally prefer 'with' blocks when they are available.
|
|
||
| .. deprecated:: 3.7 | ||
|
|
||
| Lock acquiring on ``await lock`` or ``yield from lock`` and |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
"Lock acquiring on" -> "Lock acquiring using"
|
All notes are fixed |
| @@ -260,6 +232,8 @@ Semaphore | |||
| 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>`. | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Semaphores also support...
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Nice catch
|
|
||
| .. class:: BoundedSemaphore(value=1, \*, loop=None) | ||
|
|
||
| A bounded semaphore implementation. Inherit from :class:`Semaphore`. | ||
|
|
||
| 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>`. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
BoundedSemaphore also support...
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
|
Spotted a few more nits; other than that it looks good |
|
Fixed |
| @@ -139,7 +139,8 @@ Condition | |||
| object, and it is used as the underlying lock. Otherwise, | |||
| 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 | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Last nit -- drop "also"
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
https://bugs.python.org/issue32253