Skip to content

Commit a0f894e

Browse files
authored
fix: Avoid charge calls with count=0 (#665)
- follow up to #664 - I haven't managed to reproduce the actual bug with a test yet, so that will happen later
1 parent be45452 commit a0f894e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/apify/_charging.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ def calculate_chargeable() -> dict[str, int | None]:
226226
# START OF CRITICAL SECTION - no awaits here
227227

228228
# Determine the maximum amount of events that can be charged within the budget
229-
charged_count = min(count, self.calculate_max_event_charge_count_within_limit(event_name) or count)
229+
max_chargeable = self.calculate_max_event_charge_count_within_limit(event_name)
230+
charged_count = min(count, max_chargeable if max_chargeable is not None else count)
230231

231232
if charged_count == 0:
232233
return ChargeResult(

0 commit comments

Comments
 (0)