Locust exception ImportError("cannot import name 'User'",)
Locust exception ImportError("cannot import name 'User'",) END RequestId: 0fec6b92-8c39-42a7-8c14-16629a464c67
NOTE: when i used the import with HttpUser, it gives the same error. I'm trying to use the invokust with AWS Lambda, but no luck so far, below are the steps that i followed,
- installing invokust in to the python target folder (sudo pip3 install invokust --target=python-packages)
- Created the locustfile and lambda_locust(handler).
- Created a zip with all 3 files (zip -q -r lambda_locust.zip lambda_locust.py princess_locustfile.py python-packages )
- Created the lambda
- and invoked from the console.
On what OS did you run sudo pip3 install invokust --target=python-packages?
I tried on Ubuntu 18.04
More Information About the Operating System @FutureSharks Virtualization: xen Operating System: Ubuntu 18.04.5 LTS Kernel: Linux 5.4.0-1030-aws Architecture: x86-64
I think you'll have to paste your locust file also.
Locust File ` from locust import HttpLocust, TaskSet, task, between from os import environ
class WebsiteUser(HttpLocust): wait_time = between(5.0, 9.0)
@task()
def get_home_page(self):
"""
Gets /
"""
self.client.get("/")
`
Lambda_Locust File ` import sys sys.path.insert(0, "python-packages")
import logging import json from invokust.aws_lambda import get_lambda_runtime_info from invokust import LocustLoadTest, create_settings
logging.basicConfig(level=logging.INFO)
def handler(event=None, context=None): try: if event: settings = create_settings(**event) else: settings = create_settings(from_environment=True)
loadtest = LocustLoadTest(settings)
loadtest.run()
except Exception as e:
logging.error("Locust exception {0}".format(repr(e)))
else:
locust_stats = loadtest.stats()
lambda_runtime_info = get_lambda_runtime_info(context)
loadtest_results = locust_stats.copy()
loadtest_results.update(lambda_runtime_info)
json_results = json.dumps(loadtest_results)
logging.info(json_results)
return json_results
`
Lambda Test Json Object
{ "locustfile": "princess_locustfile.py", "host": "https://cms.mod.studio/", "num_clients": "30", "hatch_rate": "1", "run_time": "5m" }
The newest Error That I'm getting

Your code blocks are all messed up so it's difficult to read what you have written. But it looks like you're not importing User anywhere so the issue title does not make sense?