Skip to content

Commit

Permalink
renamed new_state to current_tick
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelspagl committed Sep 7, 2022
1 parent d6715e9 commit 696ba58
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ def start_shape(self) -> None:
def shape_worker(self) -> None:
logger.info("Shape worker starting")
while self.state == STATE_INIT or self.state == STATE_SPAWNING or self.state == STATE_RUNNING:
new_state: Union[Tuple[int, float], Tuple[int, float, Optional[List[Type[User]]]], None] = (
current_tick: Union[Tuple[int, float], Tuple[int, float, Optional[List[Type[User]]]], None] = (
self.environment.shape_class.tick() if self.environment.shape_class is not None else None
)
if new_state is None:
if current_tick is None:
logger.info("Shape test stopping")
if self.environment.parsed_options and self.environment.parsed_options.headless:
self.quit()
Expand All @@ -364,14 +364,14 @@ def shape_worker(self) -> None:
self.shape_greenlet = None
self.shape_last_state = None
return
elif self.shape_last_state == new_state:
elif self.shape_last_state == current_tick:
gevent.sleep(1)
else:
if len(new_state) == 2:
user_count, spawn_rate = new_state # type: ignore
if len(current_tick) == 2:
user_count, spawn_rate = current_tick # type: ignore
user_classes = None
else:
user_count, spawn_rate, user_classes = new_state # type: ignore
user_count, spawn_rate, user_classes = current_tick # type: ignore
logger.info("Shape test updating to %d users at %.2f spawn rate" % (user_count, spawn_rate))
# TODO: This `self.start()` call is blocking until the ramp-up is completed. This can leads
# to unexpected behaviours such as the one in the following example:
Expand All @@ -387,7 +387,7 @@ def shape_worker(self) -> None:
# `(user_count - prev_user_count) / spawn_rate` in order to limit the runtime
# of each load test shape stage.
self.start(user_count=user_count, spawn_rate=spawn_rate, user_classes=user_classes)
self.shape_last_state = new_state
self.shape_last_state = current_tick

def stop(self) -> None:
"""
Expand Down Expand Up @@ -495,7 +495,6 @@ def _start(self, user_count: int, spawn_rate: float, wait: bool = False, user_cl
if wait and user_count - self.user_count > spawn_rate:
raise ValueError("wait is True but the amount of users to add is greater than the spawn rate")


for user_class in self.user_classes:
if self.environment.host:
user_class.host = self.environment.host
Expand Down

0 comments on commit 696ba58

Please sign in to comment.