From e91371573a84d4a68d6107f33c392b8718f2f26f Mon Sep 17 00:00:00 2001 From: Sebastiaan Huber Date: Thu, 13 Jul 2023 15:28:23 +0200 Subject: [PATCH] `Manager`: Catch `TimeoutError` when closing communicator The exception is caught and logged as a warning. --- src/aiida/manage/manager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/aiida/manage/manager.py b/src/aiida/manage/manager.py index c84b39f903..8621b324f4 100644 --- a/src/aiida/manage/manager.py +++ b/src/aiida/manage/manager.py @@ -68,6 +68,8 @@ class Manager: def __init__(self) -> None: """Construct a new instance.""" + from aiida.common.log import AIIDA_LOGGER + # note: the config currently references the global variables self._broker: Optional['Broker'] = None self._profile: Optional['Profile'] = None @@ -76,6 +78,7 @@ def __init__(self) -> None: self._process_controller: Optional['RemoteProcessThreadController'] = None self._persister: Optional['AiiDAPersister'] = None self._runner: Optional['Runner'] = None + self.logger = AIIDA_LOGGER.getChild(__name__) @staticmethod def get_config(create=False) -> 'Config': @@ -165,8 +168,15 @@ def reset_profile_storage(self) -> None: def reset_broker(self) -> None: """Reset the communicator.""" + from concurrent import futures + if self._broker is not None: + try: + self._broker.close() + except futures.TimeoutError as exception: + self.logger.warning(f'Call to close the broker timed out: {exception}') self._broker.close() + self._broker = None self._process_controller = None