This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Typo in example for async with statement with condition
Type: enhancement Stage: resolved
Components: asyncio Versions: Python 3.8
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: asvetlov, docs@python, eamanu, mhchia, willingc, yselivanov
Priority: normal Keywords: easy, patch, patch, patch, patch

Created on 2019-01-25 10:44 by mhchia, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11681 merged mhchia, 2019-01-26 05:54
PR 11681 merged mhchia, 2019-01-26 05:54
PR 11681 merged mhchia, 2019-01-26 05:54
PR 11681 merged mhchia, 2019-01-26 05:54
PR 16720 merged miss-islington, 2019-10-11 17:24
Messages (5)
msg334349 - (view) Author: Kevin Mai-Hsuan Chia (mhchia) * Date: 2019-01-25 10:44
In the [example](https://docs.python.org/3.8/library/asyncio-sync.html#asyncio.Condition) of the equivalent code to the `async with statement`:
```python
cond = asyncio.Condition()

# ... later
await lock.acquire()
try:
    await cond.wait()
finally:
    lock.release()
```

`lock.acquire()` should be replaced by `cond.acquire()`, and `lock.release()` replaced by `cond.release()`. So the resulting code snippet becomes:

```python
cond = asyncio.Condition()

# ... later
await cond.acquire()
try:
    await cond.wait()
finally:
    cond.release()
```
msg334350 - (view) Author: Kevin Mai-Hsuan Chia (mhchia) * Date: 2019-01-25 10:45
In the [example](https://docs.python.org/3.8/library/asyncio-sync.html#asyncio.Condition) of the equivalent code to the `async with` statement:
```python
cond = asyncio.Condition()

# ... later
await lock.acquire()
try:
    await cond.wait()
finally:
    lock.release()
```

`lock.acquire()` should be replaced by `cond.acquire()`, and `lock.release()` replaced by `cond.release()`. So the resulting code snippet becomes:

```python
cond = asyncio.Condition()

# ... later
await cond.acquire()
try:
    await cond.wait()
finally:
    cond.release()
```
msg334376 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2019-01-25 23:10
Please submit a PR!
msg336310 - (view) Author: Emmanuel Arias (eamanu) * Date: 2019-02-22 13:48
This issue could be closed, right?
msg336318 - (view) Author: Kevin Mai-Hsuan Chia (mhchia) * Date: 2019-02-22 14:44
Cool! Thanks for the reminder.
History
Date User Action Args
2022-04-11 14:59:10adminsetgithub: 80007
2019-10-11 17:24:08miss-islingtonsetpull_requests: + pull_request16297
2019-02-22 14:44:26mhchiasetstatus: open -> closed

messages: + msg336318
stage: patch review -> resolved
2019-02-22 13:48:48eamanusetnosy: + eamanu
messages: + msg336310
2019-01-26 05:55:05mhchiasetkeywords: + patch
stage: patch review
pull_requests: + pull_request11513
2019-01-26 05:54:58mhchiasetkeywords: + patch
stage: (no value)
pull_requests: + pull_request11514
2019-01-26 05:54:50mhchiasetkeywords: + patch
stage: (no value)
pull_requests: + pull_request11512
2019-01-26 05:54:41mhchiasetkeywords: + patch
stage: (no value)
pull_requests: + pull_request11511
2019-01-25 23:45:50willingcsetnosy: + willingc
2019-01-25 23:10:28yselivanovsetnosy: + asvetlov, yselivanov
messages: + msg334376

components: + asyncio, - Documentation
keywords: + easy
2019-01-25 10:45:14mhchiasetmessages: + msg334350
2019-01-25 10:44:12mhchiacreate