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

SequentialTaskSet is broken when using local class members (headless mode) #1379

Closed
efology opened this issue May 18, 2020 · 3 comments
Closed
Labels

Comments

@efology
Copy link
Contributor

efology commented May 18, 2020

Describe the bug

Trying to execute a SequentialTaskSet in headless mode, store result's from first task, and use it in second task

Expected behavior

Execute first task, retrieve json, store it as dict in SequentialTaskSet object, execute second task and access the variable.

Actual behavior

Execute first task, json is retrieved, stored. In second task upon trying to access the stored data, I get following exceptions:
1.) AttributeError: 'dict' object has no attribute '_state'
2.) AttributeError: 'dict' object has no attribute 'environment'

Steps to reproduce

Start provided mockserver.py (flask) on localhost:5000, then run provided locust file (sequence_test.py) with command lines specified

Environment

  • OS:
    Ubuntu 18.04.4 LTS running in WSL
    Linux PSALA059 4.4.0-18990-Microsoft Add/improve support for running Locust distributed #1-Microsoft Sat Sep 21 17:04:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Python version:
    3.6.9
  • Locust version:
    locust 1.0.1
  • Locust command line that you ran:
    run master locust:
    locust -f sequence_test.py --host=http://localhost:5000 --master --expect-workers=1 --headless -u 1 -r 1 -t 1h

run worker locust:
locust -f sequence_test.py --worker --master-host=127.0.0.1 --host=http://localhost:5000

@efology efology added the bug label May 18, 2020
@cyberw
Copy link
Collaborator

cyberw commented May 18, 2020

Hi! I think the problem is that you're overwriting the self.user variable. It refers to the User class (it used to be self.locust). Name it anything else and it should work.

@cyberw
Copy link
Collaborator

cyberw commented May 18, 2020

We could prevent this kind of issues by making user a read-only property. Probably wasnt as big a problem when the variable name was more uncommon (locust), but now I can definitely see more people running in to this.

Something like this.

class TaskSet(object):
    def __init__(self, parent):
        self._user = ... # instead of self.user = ...

    @property
    def user(self):
        return self._user

@efology
Copy link
Contributor Author

efology commented May 18, 2020

ooooh I see :) yeah it makes sense, I'll rename it
EDIT: it works now, thanks!

@efology efology closed this as completed May 18, 2020
cyberw added a commit that referenced this issue May 22, 2020
…ead-only-properties

Make TaskSet .user and .parent read only properties, avoids / fixes #1379
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants