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

Method _dispatcher

locust/dispatch.py:152–183  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

150 self._worker_nodes = sorted(self._worker_nodes, key=lambda worker: (worker._index_within_host, worker.id))
151
152 def _dispatcher(self) -> Generator[dict[str, dict[str, int]]]:
153 self._dispatch_in_progress = True
154
155 if self._rebalance:
156 self._rebalance = False
157 yield self._users_on_workers
158 if self._current_user_count == self._target_user_count:
159 return
160
161 if self._current_user_count == self._target_user_count:
162 yield self._initial_users_on_workers
163 self._dispatch_in_progress = False
164 return
165
166 while self._current_user_count < self._target_user_count:
167 with self._wait_between_dispatch_iteration_context():
168 yield self._add_users_on_workers()
169 if self._rebalance:
170 self._rebalance = False
171 yield self._users_on_workers
172 if self._no_user_to_spawn:
173 self._no_user_to_spawn = False
174 break
175
176 while self._current_user_count > self._target_user_count:
177 with self._wait_between_dispatch_iteration_context():
178 yield self._remove_users_from_workers()
179 if self._rebalance:
180 self._rebalance = False
181 yield self._users_on_workers
182
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

Callers 1

new_dispatchMethod · 0.95

Tested by

no test coverage detected