Beispiel #1
0
 def run(self):
     try:
         self.task_set(self).run()
     except StopLocust:
         pass
     except (RescheduleTask, RescheduleTaskImmediately) as e:
         raise LocustError, LocustError("A task inside a Locust class' main TaskSet (`%s.task_set` of type `%s`) seems to have called interrupt() or raised an InterruptTaskSet exception. The interrupt() function is used to hand over execution to a parent TaskSet, and should never be called in the main TaskSet which a Locust class' task_set attribute points to." % (type(self).__name__, self.task_set.__name__)), sys.exc_info()[2]
Beispiel #2
0
    def __init__(self, parent):
        self._avg_wait = 0
        self._avg_wait_ctr = 0
        self._task_queue = []
        self._time_start = time()

        if isinstance(parent, TaskSet):
            self.locust = parent.locust
        elif isinstance(parent, Locust):
            self.locust = parent
        else:
            raise LocustError(
                "TaskSet should be called with Locust instance or TaskSet instance as first argument"
            )

        self.parent = parent
        self.client = self.locust.client

        # if this class doesn't have a min_wait, max_wait or avg_wait defined, copy it from Locust
        if not self.min_wait:
            self.min_wait = self.locust.min_wait
        if not self.max_wait:
            self.max_wait = self.locust.max_wait
        if not self.avg_wait:
            self.avg_wait = self.locust.avg_wait
Beispiel #3
0
 def __init__(self):
     super(HttpLocust, self).__init__()
     if self.host is None:
         raise LocustError("You must specify the base host. Either in the host attribute in the Locust class, or on the command line using the --host option.")
     
     self.client = HttpSession(base_url=self.host)
     self.ws_client = SocketClient()
Beispiel #4
0
    def __init__(self):
        super(Locust, self).__init__()
        if self.host is None:
            raise LocustError(
                "You must specify the base host. Either in the host attribute in the Locust class, or on the command line using the --host option."
            )

        self.client = HttpBrowser(self.host, self.gzip)
Beispiel #5
0
 def __getattr__(self, _):
     raise LocustError(
         "No client instantiated. Did you intend to inherit from HttpLocust?"
     )