Skip to content

Commit e2716fe

Browse files
committed
Fix profile_configure_rabbitmq corrupting global profile state
`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 017dd42 commit e2716fe

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
@@ -181,10 +181,16 @@ def profile_configure_rabbitmq(ctx, /, profile, non_interactive, force, **kwargs
181181
else:
182182
echo.echo_success('Connected to RabbitMQ with the provided connection parameters')
183183

184-
from aiida.engine.daemon.client import get_daemon_client
184+
daemon_client = None
185+
daemon_running = False
185186

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

189195
if daemon_running:
190196
echo.echo_warning('The daemon is currently running. It will need to be restarted for changes to take effect.')
@@ -196,7 +202,7 @@ def profile_configure_rabbitmq(ctx, /, profile, non_interactive, force, **kwargs
196202

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

199-
if daemon_running:
205+
if daemon_running and daemon_client is not None:
200206
echo.echo_report('Restarting the daemon...')
201207
daemon_client.restart_daemon()
202208
echo.echo_success('Daemon restarted successfully.')

0 commit comments

Comments
 (0)