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

How to handle ConnectionStateErrors when looking up for adapters and closed connections #271

Open
ale-rt opened this issue Jun 8, 2023 · 4 comments

Comments

@ale-rt
Copy link
Member

ale-rt commented Jun 8, 2023

When we look up for adapters:

byorder = registry._adapters

We might have:

  1. a closed connection
  2. and a persistent adapter registry

See:

(Pdb++) self._registry.ro[0]
<zope.component.persistentregistry.PersistentAdapterRegistry object at 0x7fcbd097b3f0 oid 0x969d3f9388a51b2 in <Connection at 7fcbd22f1010>>
(Pdb++) self._registry.ro[0]._subscribers.__class__
<class 'persistent.list.PersistentList'>

This causes the _uncached_subscriptions to raise a ConnectionStateError.

The issue happens since zope.component 5, before the persistent adapter registry was storing a list, see:

What would be the best way to handle this issue?
Adding a:

try:
    ...
except ConnectionStateError:
    continue

might be an idea?

Originally discovered while debugging:

plone/plone.testing#83

What version of Python and Zope/Addons I am using:

Tested on Plone 6 with:

  • Python 3.8 and Python 3.11
  • zope.interface 6.0
  • zope.component 5.1.0
@ale-rt
Copy link
Member Author

ale-rt commented Jun 8, 2023

CCing @jamadden because he worked on zopefoundation/zope.component#53

@d-maurer
Copy link
Contributor

d-maurer commented Jun 8, 2023 via email

@ale-rt
Copy link
Member Author

ale-rt commented Jun 8, 2023

I agree that this is not good.
Probably that PersistentList does not even have what I am looking for :)
But they point is that with the previous implementation (which used a list instead of a PersistentList) it was working.

@d-maurer
Copy link
Contributor

d-maurer commented Jun 8, 2023 via email

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

No branches or pull requests

2 participants