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

Fixed issue with invoking _close() on closed event loop #3438

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vladvildanov
Copy link
Collaborator

@vladvildanov vladvildanov commented Nov 18, 2024

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

Closes #3431
Closes #3239

This PR fixes an issue when connection closed by garbage collector after event loop was closed. Also fixed an issue with __repr__ method tried to reference object already removed by garbage collector, by changing weak reference to strong reference.

Copy link

@teodorfn teodorfn left a comment

Choose a reason for hiding this comment

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

LGTM. Tested and verified.

When using versions 5.0.2 to 5.2.0 i get RuntimeError: Event loop is closed (which was not an issue in versions <=5.0.1).

With this fix I don't get the error anymore. Thanks!

Comment on lines -120 to +119
self.connection_kwargs["connection_pool"] = weakref.proxy(self)
self.connection_kwargs["connection_pool"] = self
Copy link
Contributor

Choose a reason for hiding this comment

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

This sort of change has me wonder why it was a weakref in the first place – probably for a reason?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same concerns here as @akx. We need to ensure with a test that it doesn't create a circular reference and prevents garbage collecting unused SentinelConnectionPool objects.

Copy link
Collaborator Author

@vladvildanov vladvildanov Nov 19, 2024

Choose a reason for hiding this comment

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

But isn't it already covered by current tests in test_sentinel.py? I mean, GC is always take in action after the tests been executed. I also had a doubts about this, but I didn't find any reason why weakref was used and current tests works as expected. Do you have a specific test case in mind that is worth to add?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants