Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/apify/_charging.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ class ChargingManagerImplementation(ChargingManager):
LOCAL_CHARGING_LOG_DATASET_NAME = 'charging-log'

def __init__(self, configuration: Configuration, client: ApifyClientAsync) -> None:
self._max_total_charge_usd = configuration.max_total_charge_usd or Decimal('inf')
self._max_total_charge_usd = (
configuration.max_total_charge_usd if configuration.max_total_charge_usd is not None else Decimal('inf')
)
self._configuration = configuration
self._is_at_home = configuration.is_at_home
self._actor_run_id = configuration.actor_run_id
Expand Down Expand Up @@ -413,7 +415,11 @@ async def _fetch_pricing_info(self) -> _FetchedPricingInfoDict:
return _FetchedPricingInfoDict(
pricing_info=self._configuration.actor_pricing_info,
charged_event_counts=self._configuration.charged_event_counts,
max_total_charge_usd=self._configuration.max_total_charge_usd or Decimal('inf'),
max_total_charge_usd=(
self._configuration.max_total_charge_usd
if self._configuration.max_total_charge_usd is not None
else Decimal('inf')
),
)

# Fall back to API call
Expand All @@ -436,7 +442,11 @@ async def _fetch_pricing_info(self) -> _FetchedPricingInfoDict:
return _FetchedPricingInfoDict(
pricing_info=None,
charged_event_counts={},
max_total_charge_usd=self._configuration.max_total_charge_usd or Decimal('inf'),
max_total_charge_usd=(
self._configuration.max_total_charge_usd
if self._configuration.max_total_charge_usd is not None
else Decimal('inf')
),
)

def _get_event_price(self, event_name: str) -> Decimal:
Expand Down
Loading