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

Make the Python PickleCache run a GC when it evicts weakly-referenced objects. #162

Merged
merged 2 commits into from
Apr 13, 2021

Conversation

jamadden
Copy link
Member

This fixes hard-to-debug ZODB ConnectionStateError cases with persistent zope.component registrations on PyPy.

I tried to come up with a test that would also fail on CPython using circular references, but did not succeed (because part of evicting objects is clearing their dict, breaking the reference cycle).

Fixes #149. Well, band-aids it anyway. I'd like to think of a better way (the assumption that weakrefs are cleared immediately is pretty baked-in to zope.interface, at least when used with ZODB).

Currently based on #161 to avoid conflicts; only the last commit is relevant.

@jamadden
Copy link
Member Author

A version of this fix is present in nti.testing where it was necessary to test persistent zope.component registries under PyPy.

Are there any interested reviewers?

@jamadden jamadden requested a review from mgedmin April 1, 2021 13:20
@jamadden jamadden requested a review from icemac April 12, 2021 12:17
Copy link
Member

@icemac icemac left a comment

Choose a reason for hiding this comment

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

I cannot judge the code, as I do not know enough about it.
I read the changes in the last commit and they look fine for me.
I tested locally by removing the gc.collect() call and it fails four tests on PyPy2 and PyPy3 but on CPython the call is not needed. That's fine as it was the goal of the PR.

persistent/tests/test_picklecache.py Outdated Show resolved Hide resolved
jamadden and others added 2 commits April 13, 2021 05:23
… objects.

This fixes hard-to-debug ZODB ConnectionStateError cases with persistent zope.component registrations on PyPy.

I tried to come up with a test that would also fail on CPython using circular references, but did not succeed (because part of evicting objects is clearing their dict, breaking the reference cycle).

Fixes #149
Co-authored-by: Michael Howitz <mh@gocept.com>
@jamadden
Copy link
Member Author

I read the changes in the last commit and they look fine for me. I tested locally…

Thank you for reviewing, and thank you for testing. I plan to move ahead with merging and releasing this now.

@jamadden jamadden merged commit 002bd21 into master Apr 13, 2021
@jamadden jamadden deleted the issue149 branch April 13, 2021 10:54
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.

PyPy: Sweeping the cache may need to call gc.collect()
2 participants