Skip to content

Commit 36159b9

Browse files
committed
Fix minor bugs
1 parent fd48836 commit 36159b9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/apify/_charging.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def calculate_chargeable() -> dict[str, int | None]:
139139
if self._actor_run_id is None:
140140
raise RuntimeError('Actor run ID not configured')
141141

142-
if event_name is self._pricing_info:
142+
if event_name in self._pricing_info:
143143
await self._client.run(self._actor_run_id).charge(event_name, charged_count)
144144
else:
145145
logger.warning(f"Attempting to charge for an unknown event '{event_name}'")
@@ -195,7 +195,8 @@ def calculate_max_event_charge_count_within_limit(self, event_name: str) -> int
195195
if not price:
196196
return None
197197

198-
return math.floor((self._max_total_charge_usd - self.calculate_total_charged_amount()) / price)
198+
result = (self._max_total_charge_usd - self.calculate_total_charged_amount()) / price
199+
return math.floor(result) if result.is_finite() else None
199200

200201
def get_pricing_info(self) -> ActorPricingInfo:
201202
if self._charging_state is None:

0 commit comments

Comments
 (0)