Skip to content

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

Description

@ale-rt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions