Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix respawning of pool instances have different names #2493

Merged
merged 25 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0613009
Using current names
germa89 Nov 8, 2023
8137069
enhancing test
germa89 Nov 8, 2023
8995f31
Merge branch 'main' into fix/pool-names-changes-when-respawning
germa89 Nov 8, 2023
095f77f
Merge branch 'main' into fix/pool-names-changes-when-respawning
germa89 Nov 8, 2023
61fe091
Merge branch 'main' into fix/pool-names-changes-when-respawning
germa89 Nov 8, 2023
9e1f76a
Merge branch 'main' into fix/pool-names-changes-when-respawning
germa89 Nov 20, 2023
1c5e844
Merge branch 'main' into fix/pool-names-changes-when-respawning
germa89 Nov 20, 2023
b4430e1
Update tests/test_pool.py
germa89 Nov 20, 2023
7a681c1
Merge branch 'main' into fix/pool-names-changes-when-respawning
germa89 Nov 20, 2023
ce868a6
empty commit to trigger CICD
germa89 Nov 21, 2023
3722772
removing name argument since it is not used by wrapped functions
germa89 Nov 21, 2023
516f350
Using a clear option for thread name.
germa89 Nov 21, 2023
8e567b5
Merge branch 'main' into fix/pool-names-changes-when-respawning
germa89 Nov 21, 2023
0f8d721
empty commit
germa89 Nov 21, 2023
c2aabab
Merge branch 'fix/pool-names-changes-when-respawning' of https://gith…
germa89 Nov 21, 2023
f67620a
Merge branch 'main' into fix/pool-names-changes-when-respawning
germa89 Nov 21, 2023
2069545
Avoiding timeout
germa89 Nov 22, 2023
929048f
Increasing timeout and unmarking test
germa89 Nov 22, 2023
ac0060a
disabling rerun
germa89 Nov 22, 2023
ea70ce5
Adding name to spawn_mapdl
germa89 Nov 23, 2023
ae65fdb
Adding more checks while spawning instances
germa89 Nov 23, 2023
1adebb2
forcing override (deleting lock file)
germa89 Nov 23, 2023
24b725e
Merge branch 'main' into fix/pool-names-changes-when-respawning
germa89 Nov 23, 2023
3b4155f
Merge branch 'main' into fix/pool-names-changes-when-respawning
germa89 Jan 4, 2024
5200c2f
fixing conftest requirement for windows libraries
germa89 Jan 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/ansys/mapdl/core/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def __init__(

# monitor pool if requested
if restart_failed:
self._pool_monitor_thread = self._monitor_pool(name="Monitoring_Thread")
self._pool_monitor_thread = self._monitor_pool()

self._verify_unique_ports()

Expand Down Expand Up @@ -686,22 +686,21 @@ def _spawn_mapdl(
self._spawning_i -= 1

@threaded_daemon
def _monitor_pool(self, refresh=1.0, name=""):
def _monitor_pool(self, refresh=1.0):
"""Checks if instances within a pool have exited (failed) and
restarts them.
"""
while self._active:
for index, instance in enumerate(self._instances):
name = self._names[index]
if not instance: # encountered placeholder
continue
if instance._exited:
try:
# use the next port after the current available port
self._spawning_i += 1
port = max(self._ports) + 1
self._spawn_mapdl(
index, port=port, name=f"Instance {index}"
).join()
self._spawn_mapdl(index, port=port, name=name).join()
except Exception as e:
LOG.error(e, exc_info=True)
self._spawning_i -= 1
Expand Down
4 changes: 2 additions & 2 deletions tests/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ def test_invalid_exec():
@requires("local")
def test_heal(pool):
pool_sz = len(pool)
pool_names = pool._names
pool[0].exit()
germa89 marked this conversation as resolved.
Show resolved Hide resolved
pool[1].exit()
pool[2].exit()

time.sleep(1) # wait for shutdown
timeout = time.time() + TWAIT
Expand All @@ -103,6 +102,7 @@ def test_heal(pool):
if time.time() > timeout:
raise TimeoutError(f"Failed to restart instance in {TWAIT} seconds")

assert pool._names == pool_names
assert len(pool) == pool_sz
pool._verify_unique_ports()

Expand Down
Loading