From 931bc02165736243c33d1dc55ef0ac46ec06a55e Mon Sep 17 00:00:00 2001 From: z0z0r4 Date: Tue, 6 Aug 2024 22:32:54 +0800 Subject: [PATCH] check for duplicate actor_names in decorator --- dramatiq/actor.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dramatiq/actor.py b/dramatiq/actor.py index ad9fcbaf..fbca5ea0 100644 --- a/dramatiq/actor.py +++ b/dramatiq/actor.py @@ -64,6 +64,9 @@ def __init__( priority: int, options: Dict[str, Any], ) -> None: + if actor_name in broker.actors: + raise ValueError(f"An actor named {actor_name!r} is already registered.") + self.logger = get_logger(fn.__module__, actor_name) self.fn = async_to_sync(fn) if iscoroutinefunction(fn) else fn self.broker = broker