def run(self, *args, **kwargs): self.args = args self.kwargs = kwargs try: self.on_start() except InterruptTaskSet as e: if e.reschedule: raise RescheduleTaskImmediately(e.reschedule).with_traceback( sys.exc_info()[2]) else: raise RescheduleTask(e.reschedule).with_traceback( sys.exc_info()[2]) while (True): try: if not self._task_queue: self.schedule_task(self.get_next_task()) try: self._check_stop_condition() self.execute_next_task() except RescheduleTaskImmediately: pass except RescheduleTask: self.wait() else: self.wait() except InterruptTaskSet as e: self.on_stop() if e.reschedule: raise RescheduleTaskImmediately(e.reschedule) from e else: raise RescheduleTask(e.reschedule) from e except (StopUser, GreenletExit): self.on_stop() raise except Exception as e: self.user.environment.events.user_error.fire( user_instance=self, exception=e, tb=sys.exc_info()[2]) if self.user.environment.catch_exceptions: logger.error("%s\n%s", e, traceback.format_exc()) self.wait() else: raise
def run(self, *args, **kwargs): self.args = args self.kwargs = kwargs try: if hasattr(self, "on_start"): self.on_start() except InterruptTaskSet as e: if e.reschedule: six.reraise(RescheduleTaskImmediately, RescheduleTaskImmediately(e.reschedule), sys.exc_info()[2]) else: six.reraise(RescheduleTask, RescheduleTask(e.reschedule), sys.exc_info()[2]) while (True): try: if self.locust.stop_timeout is not None and time() - self._time_start > self.locust.stop_timeout: return if not self._task_queue: self.schedule_task(self.get_next_task()) try: self.execute_next_task() except RescheduleTaskImmediately: pass except RescheduleTask: self.wait() else: self.wait() except InterruptTaskSet as e: if e.reschedule: six.reraise(RescheduleTaskImmediately, RescheduleTaskImmediately(e.reschedule), sys.exc_info()[2]) else: six.reraise(RescheduleTask, RescheduleTask(e.reschedule), sys.exc_info()[2]) except StopLocust: raise except GreenletExit: raise except Exception as e: events.locust_error.fire(locust_instance=self, exception=e, tb=sys.exc_info()[2]) if self.locust._catch_exceptions: sys.stderr.write("\n" + traceback.format_exc()) self.wait() else: raise
def run(self): try: self.on_start() except InterruptTaskSet as e: if e.reschedule: raise RescheduleTaskImmediately(e.reschedule).with_traceback( e.__traceback__) else: raise RescheduleTask(e.reschedule).with_traceback( e.__traceback__) while True: try: if not self._task_queue: self.schedule_task(self.get_next_task()) try: if self.user._state == LOCUST_STATE_STOPPING: raise StopUser() self.execute_next_task() except RescheduleTaskImmediately: pass except RescheduleTask: self.wait() else: self.wait() except InterruptTaskSet as e: self.on_stop() if e.reschedule: raise RescheduleTaskImmediately(e.reschedule) from e else: raise RescheduleTask(e.reschedule) from e except (StopUser, GreenletExit): self.on_stop() raise except Exception as e: self.user.environment.events.user_error.fire( user_instance=self, exception=e, tb=e.__traceback__) if self.user.environment.catch_exceptions: logger.error("%s\n%s", e, traceback.format_exc()) self.wait() else: raise