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

Regenerate heartbeat by setting heartbeat_liveness instead of HEARTBEAT_LIVENESS #2977

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 5 additions & 4 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def __init__(self, environment) -> None:
self.client_id = socket.gethostname() + "_" + uuid4().hex
self.worker_count = 1
# Only when running in standalone mode (non-distributed)
self._local_worker_node = WorkerNode(id="local")
self._local_worker_node = WorkerNode(id="local", heartbeat_liveness=HEARTBEAT_LIVENESS)
self._local_worker_node.user_classes_count = self.user_classes_count

# register listener that's logs the exception for the local runner
Expand Down Expand Up @@ -573,10 +573,11 @@ def __init__(self, *args, **kwargs) -> None:


class WorkerNode:
def __init__(self, id: str, state=STATE_INIT, heartbeat_liveness=HEARTBEAT_LIVENESS) -> None:
def __init__(self, id: str, state=STATE_INIT, heartbeat_liveness: int = HEARTBEAT_LIVENESS) -> None:
self.id: str = id
self.state = state
self.heartbeat = heartbeat_liveness
self.heartbeat: int = heartbeat_liveness
self.heartbeat_liveness: int = heartbeat_liveness
self.cpu_usage: int = 0
self.cpu_warning_emitted = False
self.memory_usage: int = 0
Expand Down Expand Up @@ -1083,7 +1084,7 @@ def client_listener(self) -> NoReturn:
elif msg.type == "heartbeat":
if msg.node_id in self.clients:
c = self.clients[msg.node_id]
c.heartbeat = HEARTBEAT_LIVENESS
c.heartbeat = c.heartbeat_liveness
client_state = msg.data["state"]
if c.state == STATE_MISSING:
logger.info(f"Worker {str(c.id)} self-healed with heartbeat, setting state to {client_state}.")
Expand Down