You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Overcharge by one event when the budget is exhausted #1187
When a charge exceeds the remaining maxTotalChargeUsd budget, ChargingManager.charge() caps the count with min() (source), and the push-data limits do the same for dataset items (compute_push_data_limit, PPE dataset mixin). The platform never sees a charge over the budget, so an Actor that ignores the returned ChargeResult keeps running and doing unpaid work until it times out.
charge() charges max_chargeable + 1 events when count exceeds the remaining budget and the total charged amount is not already over the limit.
push_data() and the default-dataset PPE path let one item through when the budget cannot cover a single item, under the same condition; a partially covered push is still capped to what the budget allows.
Unit tests updated, including the local PPE mode.
Implementation notes
ChargingManager.charge() (_charging.py#L344-L353): when count > max_chargeable and calculate_total_charged_amount() <= max_total_charge_usd, charge max_chargeable + 1; when the run is already strictly over budget, charge 0. Port the condition from JS charge() as is.
compute_push_data_limit() (#L467-L484) and DatasetClientPpeMixin._compute_limit_for_push() (_ppe_dataset_mixin.py#L12-L18): follow JS calculatePushDataLimit(), letting one item through only when the budget can't cover a single one.
ChargeResult.event_charge_limit_reached must still report True after the extra event.
Update the capped-count assertions in tests/unit/actor/test_actor_charge.py and tests/unit/actor/test_charging_manager.py, and add cases for the "already over budget" branch and the local (off-platform) mode.
Activity