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

How to retrieve host argument for custom client #238

Closed
livfc opened this issue Feb 1, 2015 · 2 comments
Closed

How to retrieve host argument for custom client #238

livfc opened this issue Feb 1, 2015 · 2 comments

Comments

@livfc
Copy link

livfc commented Feb 1, 2015

Hi,

I have developed a custom client and would like to use the host variable that can be passed on the command line when starting locust when instantiating my custom class

locust --host=http://example.com -f locustfile.py

I have interrogated the Locust object in my custom class without success.

class CustomClientLocust(Locust):
    def __init__(self):
         super(CustomClientLocust, self).__init__()
         print str(Locust.__dict__)
         hostname = Locust.host
         self.client = MyCustomClient(hostname)

I can see that the options.host argument is set in the LocustRunner class, but we don't seem to have access to this in the Locust file?

Any tips on where I should be looking would be gratefully received!

Thanks!

@vrde
Copy link

vrde commented Mar 11, 2015

👍

I have the same need but I cannot find a way to retrieve the host option. I checked main.py but apparently the options object is not stored in a location I can access from my TaskSet.

@vrde
Copy link

vrde commented Mar 11, 2015

OK I found a solution. If you are subclassing Locust then you can access host using self.host.
If you are subclassing a TaskSet then you can access host using self.parent.host.

Hope this help!

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

3 participants