Skip to content

Commit f278689

Browse files
authored
Merge pull request #300 from Andrew-Chen-Wang/patch-1
(doc) Mention requiring closing Reddit http connection
2 parents d5e8743 + 8f500a4 commit f278689

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Documentation Contributors
3131
- Johanna Rührig `@TheRealVira <https://github.com/TheRealVira>`_
3232
- Sam Snarr `@sss-ng <https://github.com/sss-ng>`_
3333
- Moshe Dicker `@dickermoshe <https://github.com/dickermoshe>`_
34+
- Andrew Chen Wang `@Andrew-Chen-Wang <https://github.com/Andrew-Chen-Wang>`_
3435
- Add "Name <email (optional)> and github profile link" above this line.
3536

3637
PRAW Author

docs/getting_started/quick_start.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,25 @@ to read-only mode whenever you want:
157157
If you are uncomfortable hard-coding your credentials into your program, there are
158158
some options available to you. Please see: :ref:`configuration`.
159159

160+
Close Connections in :class:`.Reddit`
161+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
162+
163+
The asynchronous context requires closing your session when you finish using Reddit:
164+
165+
.. code-block:: python
166+
167+
reddit = asyncpraw.Reddit(...)
168+
await reddit.close()
169+
170+
Or, you can use an asynchronous context manager:
171+
172+
.. code-block:: python
173+
174+
async with asyncpraw.Reddit(...) as reddit:
175+
# do stuff with `reddit`
176+
print(await reddit.user.me())
177+
# connection is closed
178+
160179
Obtain a :class:`.Subreddit`
161180
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
162181

0 commit comments

Comments
 (0)