Skip to content

Commit

Permalink
Manager: Catch TimeoutError when closing communicator
Browse files Browse the repository at this point in the history
The exception is caught and logged as a warning.
  • Loading branch information
sphuber committed Jul 2, 2024
1 parent d86017f commit e913715
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/aiida/manage/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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':
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit e913715

Please sign in to comment.