locust対応ソースコードHttpUserプロファイリング(7)
古いルールで、まずコードを貼ります.
簡単なのは、Userの各属性を継承したことにほかならない.ここではクラス変数clientを空にし、NoClientWarningRaiser()ではない.
その他は引き続き使用しますが、インスタンス化するとclientがsessionになります.このときの最初の注目点は、インスタンス化するときに必ずhost属性があることです.
まずhostプロパティがどのように得られるかを見てみましょう.
まずUserから取りに行き、実際の過程で
class HttpUser(User):
abstract = True
client = None
def __init__(self, *args, **kwargs):
super(HttpUser, self).__init__(*args, **kwargs)
if self.host is None:
raise LocustError("You must specify the base host. Either in the host attribute in the User class, or on the command line using the --host option.")
session = HttpSession(
base_url=self.host,
request_success=self.environment.events.request_success,
request_failure=self.environment.events.request_failure,
)
session.trust_env = False
self.client = session
簡単なのは、Userの各属性を継承したことにほかならない.ここではクラス変数clientを空にし、NoClientWarningRaiser()ではない.
その他は引き続き使用しますが、インスタンス化するとclientがsessionになります.このときの最初の注目点は、インスタンス化するときに必ずhost属性があることです.
まずhostプロパティがどのように得られるかを見てみましょう.
まずUserから取りに行き、実際の過程で