From 18321d8db6195a462f102058315784ee70206f7e Mon Sep 17 00:00:00 2001 From: David Ramirez Date: Wed, 5 Jun 2024 22:54:51 +0000 Subject: [PATCH] Fixed bug with sync pacing trying to use async strats --- kytos/core/pacing.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kytos/core/pacing.py b/kytos/core/pacing.py index 87d6c3a0..5af03b9e 100644 --- a/kytos/core/pacing.py +++ b/kytos/core/pacing.py @@ -60,7 +60,7 @@ def inject_config(self, config: dict[str, dict]): } # Validate - for action, (strat, pace) in next_config.items(): + for action, (strat, _) in next_config.items(): LOG.info("Added pace for action %s", action) if strat not in available_strategies: raise ValueError( @@ -106,13 +106,16 @@ def hit(self, action_name, *keys): return strat, pace = self.pace_config[action_name] identifiers = pace, action_name, *keys - strategy = self.async_strategies[strat] + strategy = self.sync_strategies[strat] while not strategy.hit(*identifiers): window_reset, _ = strategy.get_window_stats( *identifiers ) sleep_time = window_reset - time.time() + if sleep_time <= 0: + continue + time.sleep(sleep_time)