Skip to content

Commit

Permalink
Add in comment about Empty strategies incrementing storage counters
Browse files Browse the repository at this point in the history
  • Loading branch information
Ktmi committed Jul 12, 2024
1 parent fbd451a commit de4f917
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kytos/core/pacing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def hit(
*identifiers: str,
cost: int = 1
) -> bool:
# Increment storage, to collect data on usage rate of actions
self.storage.incr(
item.key_for(*identifiers),
item.get_expiry(),
Expand All @@ -38,6 +39,7 @@ async def hit(
*identifiers: str,
cost: int = 1
) -> bool:
# Increment storage, to collect data on usage rate of actions
await self.storage.incr(
item.key_for(*identifiers),
item.get_expiry(),
Expand Down Expand Up @@ -137,7 +139,7 @@ async def ahit(self, action_name: str, *keys):
*identifiers
)
sleep_time = window_reset - time.time()

LOG.info(f'Limited reached: {identifiers}')
await asyncio.sleep(sleep_time)

def hit(self, action_name: str, *keys):
Expand All @@ -161,7 +163,7 @@ def hit(self, action_name: str, *keys):
*identifiers
)
sleep_time = window_reset - time.time()

LOG.info(f'Limited reached: {identifiers}')
if sleep_time <= 0:
continue

Expand Down

0 comments on commit de4f917

Please sign in to comment.