Skip to content

Commit 28eda58

Browse files
committed
🐛 Fix profile configure state corruption (aiidateam#7284)
`get_daemon_client(profile.name)` called `load_profile()` which switched the global manager profile, corrupting the state for all subsequent operations in the same process. Use `DaemonClient(profile)` directly and skip the daemon check entirely when no broker is configured yet.
1 parent 5920c68 commit 28eda58

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/aiida/cmdline/commands/cmd_profile.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,16 @@ def profile_configure_rabbitmq(ctx, /, profile, non_interactive, force, **kwargs
179179
else:
180180
echo.echo_success('Connected to RabbitMQ with the provided connection parameters')
181181

182-
from aiida.engine.daemon.client import get_daemon_client
182+
daemon_client = None
183+
daemon_running = False
183184

184-
daemon_client = get_daemon_client(profile.name)
185-
daemon_running = daemon_client.is_daemon_running
185+
# Only check daemon status if the profile already has a broker configured.
186+
# If no broker is configured yet, there can't be a daemon running.
187+
if profile.process_control_backend is not None:
188+
from aiida.engine.daemon.client import DaemonClient
189+
190+
daemon_client = DaemonClient(profile)
191+
daemon_running = daemon_client.is_daemon_running
186192

187193
if daemon_running:
188194
echo.echo_warning('The daemon is currently running. It will need to be restarted for changes to take effect.')
@@ -194,7 +200,7 @@ def profile_configure_rabbitmq(ctx, /, profile, non_interactive, force, **kwargs
194200

195201
echo.echo_success(f'RabbitMQ configuration for `{profile.name}` updated to: {broker_config}')
196202

197-
if daemon_running:
203+
if daemon_running and daemon_client is not None:
198204
echo.echo_report('Restarting the daemon...')
199205
daemon_client.restart_daemon()
200206
echo.echo_success('Daemon restarted successfully.')

0 commit comments

Comments
 (0)