Skip to content

Add missing await to open_file() in file I/O concurrency example - #1182

Merged
agronholm merged 2 commits into
agronholm:masterfrom
patrickwehbe:docs/fileio-await-open-file
Jun 20, 2026
Merged

agronholm merged 2 commits into
agronholm:masterfrom
patrickwehbe:docs/fileio-await-open-file

Conversation

@patrickwehbe

Copy link
Copy Markdown
Contributor

Changes

The "Limiting concurrency" example in docs/fileio.rst uses async with open_file('/foo/bar', limiter=limiter) as fp:. Since open_file() is a coroutine function, this raises TypeError: 'coroutine' object does not support the asynchronous context manager protocol when run as written.

Added the missing await so the example actually runs. It now matches the other two open_file() examples in the same file, which already use async with await open_file(...).

Checklist

If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):

  • You've added tests (in tests/) which would fail without your patch
  • You've updated the documentation (in docs/), in case of behavior changes or new
    features
  • You've added a new changelog entry (in docs/versionhistory.rst).

If this is a trivial change, like a typo fix or a code reformatting, then you can ignore
these instructions.

Patrick Wehbe and others added 2 commits June 19, 2026 22:37
The "Limiting concurrency" example used "async with open_file(...)", but open_file() is a coroutine function, so the example raised a TypeError when run. Added the missing await so it matches the other two open_file() examples in the same file.
Trivial changes don't need changelog entries.

@agronholm agronholm left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@agronholm
agronholm merged commit e10d1db into agronholm:master Jun 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants