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

Delete the CustomMessageListener class for type consistency #2221

Merged
merged 3 commits into from
Oct 12, 2022
Merged
Changes from all commits
Commits
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
11 changes: 3 additions & 8 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
Type,
Any,
cast,
Callable,
)
from uuid import uuid4

Expand Down Expand Up @@ -93,12 +94,6 @@ class ExceptionDict(TypedDict):
nodes: Set[str]


class CustomMessageListener(Protocol):
@abstractmethod
def __call__(self, environment: "Environment", msg: Message) -> None:
...


class Runner:
"""
Orchestrates the load test by starting and stopping the users.
Expand Down Expand Up @@ -130,7 +125,7 @@ def __init__(self, environment: "Environment") -> None:
self.target_user_classes_count: Dict[str, int] = {}
# target_user_count is set before the ramp-up/ramp-down occurs.
self.target_user_count: int = 0
self.custom_messages: Dict[str, CustomMessageListener] = {}
self.custom_messages: Dict[str, Callable] = {}

self._users_dispatcher: Optional[UsersDispatcher] = None

Expand Down Expand Up @@ -432,7 +427,7 @@ def log_exception(self, node_id: str, msg: str, formatted_tb: str) -> None:
row["nodes"].add(node_id)
self.exceptions[key] = row

def register_message(self, msg_type: str, listener: CustomMessageListener) -> None:
def register_message(self, msg_type: str, listener: Callable) -> None:
"""
Register a listener for a custom message from another node

Expand Down