Skip to content

Commit 3d906d7

Browse files
committed
sonar
1 parent 613501a commit 3d906d7

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

services/dask-sidecar/src/simcore_service_dask_sidecar/rabbitmq_plugin.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
from asyncio import AbstractEventLoop
44
from collections.abc import Awaitable
5+
from typing import Final
56

67
import distributed
78
from servicelib.logging_utils import log_catch, log_context
@@ -12,6 +13,10 @@
1213

1314
_logger = logging.getLogger(__name__)
1415

16+
_RABBITMQ_CONFIGURATION_ERROR: Final[str] = (
17+
"RabbitMQ client is not available. Please check the configuration."
18+
)
19+
1520

1621
class RabbitMQPlugin(distributed.WorkerPlugin):
1722
"""Dask Worker Plugin for RabbitMQ integration"""
@@ -73,21 +78,15 @@ async def _() -> None:
7378
def get_client(self) -> RabbitMQClient:
7479
"""Returns the RabbitMQ client or raises an error if not available"""
7580
if not self._client:
76-
raise ConfigurationError(
77-
msg="RabbitMQ client is not available. Please check the configuration."
78-
)
81+
raise ConfigurationError(msg=_RABBITMQ_CONFIGURATION_ERROR)
7982
return self._client
8083

8184

8285
def get_rabbitmq_client(worker: distributed.Worker) -> RabbitMQClient:
8386
"""Returns the RabbitMQ client or raises an error if not available"""
8487
if not worker.plugins:
85-
raise ConfigurationError(
86-
msg="RabbitMQ client is not available. Please check the configuration."
87-
)
88+
raise ConfigurationError(msg=_RABBITMQ_CONFIGURATION_ERROR)
8889
rabbitmq_plugin = worker.plugins.get(RabbitMQPlugin.name)
8990
if not isinstance(rabbitmq_plugin, RabbitMQPlugin):
90-
raise ConfigurationError(
91-
msg="RabbitMQ client is not available. Please check the configuration."
92-
)
91+
raise ConfigurationError(msg=_RABBITMQ_CONFIGURATION_ERROR)
9392
return rabbitmq_plugin.get_client()

0 commit comments

Comments
 (0)