Skip to content

Commit

Permalink
catch errors when disposing
Browse files Browse the repository at this point in the history
  • Loading branch information
lucyleeow committed Nov 10, 2023
1 parent 9d29e4d commit 0556eca
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/npe2/_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from collections import Counter
from fnmatch import fnmatch
from importlib import metadata
from logging import getLogger
from pathlib import Path
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -52,6 +53,8 @@
InclusionSet = Union[AbstractSetIntStr, MappingIntStrAny, None]
DisposeFunction = Callable[[], None]

logger = getLogger(__name__)

__all__ = ["PluginContext", "PluginManager"]
PluginName = str # this is `PluginManifest.name`

Expand Down Expand Up @@ -710,7 +713,10 @@ def __init__(

def _dispose(self):
while self._disposables:
self._disposables.pop()()
try:
self._disposables.pop()()
except Exception as e:
logger.warn(f'Error while disposing {self.plugin_key}; {e}')

def register_command(self, id: str, command: Optional[Callable] = None):
"""Associate a callable with a command id."""
Expand Down

0 comments on commit 0556eca

Please sign in to comment.