Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close requestor session #17

Merged
merged 3 commits into from
Jan 17, 2021
Merged

Close requestor session #17

merged 3 commits into from
Jan 17, 2021

Conversation

GerardRodes
Copy link
Contributor

Fixes #10

Feature Summary and Justification

A method to close the requestor session

.gitignore Outdated Show resolved Hide resolved
@PythonCoderAS PythonCoderAS dismissed their stale review November 22, 2020 02:40

Change has been reverted

CHANGES.rst Outdated Show resolved Hide resolved
asyncpraw/reddit.py Outdated Show resolved Hide resolved
@LilSpazJoekp
Copy link
Member

LilSpazJoekp commented Dec 13, 2020

@GerardRodes If you could re-push your changes to your branch, it should allow you to reopen this PR. After that I'll get it fixed up and merged in. Thanks!

@GerardRodes
Copy link
Contributor Author

@GerardRodes If you could re-push your changes to your branch, it should allow you to reopen this PR. After that I'll get it fixed up and merged in. Thanks!

diff --git a/asyncpraw/reddit.py b/asyncpraw/reddit.py
index ce98a3bd..dc2f9b7e 100644
--- a/asyncpraw/reddit.py
+++ b/asyncpraw/reddit.py
@@ -119,10 +119,6 @@ class Reddit:
     def __exit__(self, *_args):
         """Handle the context manager close."""
 
+    async def close(self):
+        """Close open contexts."""
+        await self.requestor.close()
+
     def __init__(
         self,
         site_name: str = None,
@@ -225,7 +221,7 @@ class Reddit:
             )
 
         self._prepare_objector()
+        self.requestor = self._prepare_asyncprawcore(requestor_class, requestor_kwargs)
-        self._prepare_asyncprawcore(requestor_class, requestor_kwargs)
 
         self.auth = models.Auth(self, None)
         """An instance of :class:`.Auth`.
@@ -422,8 +418,6 @@ class Reddit:
         else:
             self._prepare_untrusted_asyncprawcore(requestor)
 
+        return requestor
+
     def _prepare_trusted_asyncprawcore(self, requestor):
         authenticator = TrustedAuthenticator(
             requestor,

this is the diff for some reason it doesn't recognizes changes between this branch and master

@LilSpazJoekp
Copy link
Member

Yeah, I pushed the wrong branch and it brought it inline with master.

@LilSpazJoekp
Copy link
Member

@GerardRodes Could you re-push that? You'll have to rebase your local version first.

@GerardRodes
Copy link
Contributor Author

@GerardRodes Could you re-push that? You'll have to rebase your local version first.

here it is #25

@LilSpazJoekp
Copy link
Member

Could you close the other PR and reopen this one please? I'd like to keep everything together in one PR.

GerardRodes and others added 3 commits December 28, 2020 00:32
Co-authored-by: LilSpazJoekp <15524072+lilspazjoekp@users.noreply.github.com>
Co-authored-by: PythonCoderAS <13932583+PythonCoderAS@users.noreply.github.com>
Signed-off-by: LilSpazJoekp <15524072+LilSpazJoekp@users.noreply.github.com>
Signed-off-by: LilSpazJoekp <15524072+LilSpazJoekp@users.noreply.github.com>
…ddit as a synchronous context manager

Signed-off-by: LilSpazJoekp <15524072+LilSpazJoekp@users.noreply.github.com>
@coveralls
Copy link

Pull Request Test Coverage Report for Build 7d9638971da7c4742a21ea6d6b14afc3636d4c54-PR-17

  • 9 of 9 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build e0884d153eaf404ca403e7cb105f2db763cb4ffd: 0.0%
Covered Lines: 3490
Relevant Lines: 3490

💛 - Coveralls

@LilSpazJoekp LilSpazJoekp merged commit b33ad52 into praw-dev:master Jan 17, 2021
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.

Get warnings when exiting program
5 participants