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

locust master crashes on Python 3.7: AttributeError: 'bytes' object has no attribute 'encode' #980

Closed
sjagoe opened this issue Mar 15, 2019 · 1 comment

Comments

@sjagoe
Copy link

sjagoe commented Mar 15, 2019

When running distributed, locust master crashes on Python 3.7.

Description of issue

In a master/slave (no-web) locust scenario, the master crashes immediately upon the slave connecting.

Expected behavior

The test starts and runs to completion.

Actual behavior

Sending hatch jobs to 1 ready clients
Traceback (most recent call last):
  File "/Users/sjagoe/.local/share/virtualenvs/locust/bin/locust", line 10, in <module>
    sys.exit(main())
  File "/Users/sjagoe/.local/share/virtualenvs/locust/lib/python3.7/site-packages/locust/main.py", line 505, in main
    runners.locust_runner.start_hatching(options.num_clients, options.hatch_rate)
  File "/Users/sjagoe/.local/share/virtualenvs/locust/lib/python3.7/site-packages/locust/runners.py", line 310, in start_hatching
    self.server.send_to_client(Message("hatch", data, client.id))
  File "/Users/sjagoe/.local/share/virtualenvs/locust/lib/python3.7/site-packages/locust/rpc/zmqrpc.py", line 15, in send_to_client
    self.socket.send_multipart([msg.node_id.encode(), msg.serialize()])
AttributeError: 'bytes' object has no attribute 'encode'

Environment settings

  • OS: Mac OS 10.14.3 Mojave
  • Python version: 3.7.1
  • Locust version: 0.10.0

Steps to reproduce (for bug reports)

Code provided below.

  1. Start a master locust
$ locust  -t 1m -c 10 -r 10 --no-web -H http://localhost:8000 --expect-slaves 1 --master
  1. Start slave locust
$ locust --slave --master-host localhost
  1. Check the master status; it crashes with the above error

locustfile

from locust import HttpLocust, TaskSet, task


class MyTasks(TaskSet):
    @task
    def task(self):
        self.client.get('/health')


class MyLocust(HttpLocust):
    min_wait = 1000
    max_wait = 1000
    task_set = MyTasks

A basic app to test

This is not really necessary; the test doesn't get far enough to make requests.

from flask import Flask
app = Flask('app')
@app.route('/health')
def health():
    return 'OK', 200
@sjagoe
Copy link
Author

sjagoe commented Mar 15, 2019

It seems this is fixed by 0.11.0 (#972), which I hadn't noticed released.

FYI 0.11.0 doesn't appear on github releases or in the changelog, nor is it tagged.

@sjagoe sjagoe closed this as completed Mar 15, 2019
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

No branches or pull requests

1 participant