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

fix inconsistency in zmqrpc #972

Merged
merged 1 commit into from
Mar 14, 2019
Merged

fix inconsistency in zmqrpc #972

merged 1 commit into from
Mar 14, 2019

Conversation

delulu
Copy link
Contributor

@delulu delulu commented Mar 4, 2019

From zmqrpc.py, there're two new added methods send_to_client and recv_from_client for the messaging with client.

def send_to_client(self, msg):
self.socket.send_multipart([msg.node_id.encode(), msg.serialize()])
def recv(self):
data = self.socket.recv()
msg = Message.unserialize(data)
return msg
def recv_from_client(self):
data = self.socket.recv_multipart()
addr = data[0]
msg = Message.unserialize(data[1])
return addr, msg

In method send_to_client msg.node_id is supposed to be a str object, while in the context of zmqrpc msg.node_id will be assigned with the addr from the return tuple of recv_from_client, which was a bytes object.

This consistency will cause the encoding issue of addr where it's referenced, including the example below

locust/locust/web.py

Lines 126 to 134 in 87a9aa1

for slave in runners.locust_runner.clients.values():
slaves.append({"id":slave.id, "state":slave.state, "user_count": slave.user_count})
report["slaves"] = slaves
report["state"] = runners.locust_runner.state
report["user_count"] = runners.locust_runner.user_count
return jsonify(report)

the slave.id is also assigned with addr and it will be a bytes object which will cause an exception thrown from jsonify: "TypeError: Object of type 'bytes' is not JSON serializable".

@delulu
Copy link
Contributor Author

delulu commented Mar 14, 2019

@cgoldberg please have a review and merge into master, or locust won't function well on python3 in the coming release 0.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants