Skip to content

Commit

Permalink
Test manager class is a singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Dec 2, 2024
1 parent 835d13b commit e0b214c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/aiida/manage/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@

if TYPE_CHECKING:
from aiida.orm import User

from .config import Config

# global variables for aiida
Expand Down
30 changes: 30 additions & 0 deletions tests/manage/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,33 @@ def test_disconnect():
assert node.is_finished_ok
assert result == 2
manager.reset_profile() # This hangs before timing out

@pytest.mark.requires_rmq
def test_singleton():
"""Test the communicator disconnect.
When the dependency ``kiwipy`` was updated to v0.8, it introduced a problem with shutting down the communicator.
After at least one process would have been run, trying to disconnect the communcitor would time out. The problem
is related to the update of the lower lying libraries ``aio-pika`` and ``aiormq`` to v9.4 and v6.8, respectively.
After much painstaking debugging the cause could not be determined, nor a solution. This test is added to
demonstrate the problematic behavior. Getting the communicator and then disconnecting it (through calling
:meth:`aiida.manage.manager.Manager.reset_profile`) works fine. However, if a process is a run before closing it,
for example running a calcfunction, the closing of the communicator will raise a ``TimeoutError``.
"""
from aiida.manage import get_manager
from aiida.manage.manager import Manager

manager = get_manager()
manager2 = Manager()

print(manager)
print(manager2)

# manager.get_communicator()
# manager.reset_profile() # This returns just fine
#
# result, node = add_calcfunction.run_get_node(1)
# assert node.is_finished_ok
# assert result == 2
# manager.reset_profile() # This hangs before timing out

0 comments on commit e0b214c

Please sign in to comment.