Skip to content

Commit 916d2be

Browse files
Andrew-Chen-WangLilSpazJoekp
authored andcommitted
(doc) Mention requiring closing Reddit http connection
1 parent d5e8743 commit 916d2be

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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)