MCPcopy
hub / github.com/locustio/locust / new_dispatch

Method new_dispatch

locust/dispatch.py:185–215  ·  view source on GitHub ↗

Initialize a new dispatch cycle. :param target_user_count: The desired user count at the end of the dispatch cycle :param spawn_rate: The spawn rate :param user_classes: The user classes to be used for the new dispatch

(
        self, target_user_count: int, spawn_rate: float, user_classes: list[type[User]] | None = None
    )

Source from the content-addressed store, hash-verified

183 self._dispatch_in_progress = False
184
185 def new_dispatch(
186 self, target_user_count: int, spawn_rate: float, user_classes: list[type[User]] | None = None
187 ) -> None:
188 """
189 Initialize a new dispatch cycle.
190
191 :param target_user_count: The desired user count at the end of the dispatch cycle
192 :param spawn_rate: The spawn rate
193 :param user_classes: The user classes to be used for the new dispatch
194 """
195 if user_classes is not None and self._user_classes != sorted(user_classes, key=attrgetter("__name__")):
196 self._user_classes = sorted(user_classes, key=attrgetter("__name__"))
197 self._user_generator = self._user_gen()
198
199 self._target_user_count = target_user_count
200
201 self._spawn_rate = spawn_rate
202
203 self._user_count_per_dispatch_iteration = max(1, math.floor(self._spawn_rate))
204
205 self._wait_between_dispatch = self._user_count_per_dispatch_iteration / self._spawn_rate
206
207 self._initial_users_on_workers = self._users_on_workers
208
209 self._users_on_workers = self._fast_users_on_workers_copy(self._initial_users_on_workers)
210
211 self._current_user_count = self.get_current_user_count()
212
213 self._dispatcher_generator = self._dispatcher()
214
215 self._dispatch_iteration_durations.clear()
216
217 def add_worker(self, worker_node: WorkerNode) -> None:
218 """

Calls 4

_user_genMethod · 0.95
_dispatcherMethod · 0.95