(doc) Mention requiring closing Reddit http connection #300
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed the Reddit instance has an
__aexit__
method that should auto close, but it's no where mentioned in the docs.You'll get an error without explicitly closing the connection if you were to follow the get started docs
The docs in general are not really up to date either. The tutorials are also a bit outdated:
Usage of
__del__
for auto closing in async code basesThere is some kind of class in this lib that's setting
__del__
and callingclose()
that should be deleted from the code base.Even adding
.close()
showsIt's noted that trying to close the connection using
__del__
doesn't work here in the redis-py thread:https://github.com/redis/redis-py/blob/120517f88671469888a747d8e1ca1d1c2348b301/redis/asyncio/connection.py#L227
The problem ends up being the event loop is already closed at the end of the program sometimes (sometimes it's still open; it's a non-zero chance essentially). redis/redis-py#2999