Make requires_finalizer a method in both registries
@@ -83,7 +83,7 @@ class SimpleRegistry(BaseRegistry):
def __init__(self, prefix=None):
super().__init__()
self.prefix = prefix
- self.requires_finalizer = False
+ self._requires_finalizer = False
self._handlers = [] # [Handler, ...]
def __bool__(self):
@@ -110,7 +110,7 @@ class SimpleRegistry(BaseRegistry):
self.append(handler)
if requires_finalizer:
- self.requires_finalizer = True
+ self._requires_finalizer = True
return fn # to be usable as a decorator too.
@@ -130,6 +130,9 @@ class SimpleRegistry(BaseRegistry):
for handler in self._handlers:
yield handler
+ def requires_finalizer(self, resource):
+ return self._requires_finalizer
+
def get_callable_id(c):
""" Get an reasonably good id of any commonly used callable. """
@@ -218,7 +221,7 @@ class GlobalRegistry(BaseRegistry):
resource_registry = self._cause_handlers.get(resource, None)
if resource_registry is None:
return False
- return resource_registry.requires_finalizer
+ return resource_registry.requires_finalizer(resource)
_default_registry = GlobalRegistry()
