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

'Namespace' object has no attribute 'stop_timeout' in version 2.13.0 #2243

Closed
klazuka opened this issue Nov 3, 2022 · 2 comments
Closed
Labels

Comments

@klazuka
Copy link
Contributor

klazuka commented Nov 3, 2022

Describe the bug

After upgrading to 2.13.0, we started seeing the following error:

  File "/path/to/app/venv/lib/python3.9/site-packages/locust/env.py", line 84, in __init__
    self.stop_timeout = float(parsed_options.stop_timeout)
AttributeError: 'Namespace' object has no attribute 'stop_timeout'

We are using Locust as a library, and when creating the Locust Environment, we are passing in a Namespace object for parsed_options. In old versions of Locust, we did not need to pass stop_timeout, but now it appears that we do. Is this intentional?

Expected behavior

Existing code should continue to work after a minor version upgrade.

Actual behavior

An AttributeError exception is raised from within Locust.

Steps to reproduce

from argparse import Namespace
from locust.env import Environment
parsed_options = Namespace(timeout=42)
Environment(parsed_options=parsed_options)

^ the above works in 2.12.0 but fails in 2.13.0

Environment

  • OS: Linux
  • Python version: 3.9.11
  • Locust version: 2.13.0
  • Locust command line that you ran: n/a
  • Locust file contents (anonymized if necessary): n/a
@klazuka klazuka added the bug label Nov 3, 2022
@cyberw
Copy link
Collaborator

cyberw commented Nov 3, 2022

Dont construct your Environment using a Namespace. Pass arguments explicitly: Environment(stop_timeout=42)

parsed_options should either be None or an object created by argument_parser.parse_args()

@klazuka
Copy link
Contributor Author

klazuka commented Nov 7, 2022

@cyberw thanks, I figured we were doing something wrong. I created a PR to make this more clear.

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