Skip to content

Commit

Permalink
Add addr info to RPCReceiveError locustio#2
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinh committed Dec 7, 2022
1 parent 6033965 commit c5feb09
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions locust/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class RPCReceiveError(Exception):
When raised from zmqrpc, client connection should be reestablished.
"""
def __init__(self, *args: object, addr=None) -> None:
super().__init__(*args)
self.addr = addr


class AuthCredentialsError(ValueError):
Expand Down
2 changes: 1 addition & 1 deletion locust/rpc/zmqrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def recv_from_client(self):
try:
msg = Message.unserialize(data[1])
except (UnicodeDecodeError, msgerr.ExtraData) as e:
raise RPCReceiveError(f"ZMQ interrupted or corrupted message from {addr}") from e
raise RPCReceiveError("ZMQ interrupted or corrupted message", addr=addr) from e
return addr, msg

def close(self, linger=None):
Expand Down
4 changes: 3 additions & 1 deletion locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,9 @@ def client_listener(self) -> NoReturn:
client_id, msg = self.server.recv_from_client()
except RPCReceiveError as e:
# TODO: Add proper reconnect if https://github.com/zeromq/pyzmq/issues/1809 fixed
logger.error(f"Unrecognized message detected: {e}")
addr = e.addr
message = f'{e}' if not addr else f'{e} from {addr}'
logger.error(f"Unrecognized message detected: {message}")
continue
except RPCSendError as e:
logger.error(f"Error sending reconnect message to worker: {e}. Will reset RPC server.")
Expand Down

0 comments on commit c5feb09

Please sign in to comment.