From d8f510e205b4e53b604b5c908d1cb2975ecab31b Mon Sep 17 00:00:00 2001 From: Jan Buchar Date: Thu, 6 Nov 2025 15:02:00 +0100 Subject: [PATCH] fix: Avoid charge calls with count=0 --- src/apify/_charging.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/apify/_charging.py b/src/apify/_charging.py index fa53b138..014f8b2b 100644 --- a/src/apify/_charging.py +++ b/src/apify/_charging.py @@ -226,7 +226,8 @@ def calculate_chargeable() -> dict[str, int | None]: # START OF CRITICAL SECTION - no awaits here # Determine the maximum amount of events that can be charged within the budget - charged_count = min(count, self.calculate_max_event_charge_count_within_limit(event_name) or count) + max_chargeable = self.calculate_max_event_charge_count_within_limit(event_name) + charged_count = min(count, max_chargeable if max_chargeable is not None else count) if charged_count == 0: return ChargeResult(