From 564f9080670c1fe9f046ae70913c94ff89438fd0 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 53293d2879..55caa9601b 100644 --- a/src/aiida/manage/manager.py +++ b/src/aiida/manage/manager.py @@ -67,6 +67,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 @@ -75,6 +77,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': @@ -164,8 +167,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