-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathactor_charge.py
More file actions
30 lines (26 loc) · 828 Bytes
/
actor_charge.py
File metadata and controls
30 lines (26 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from apify import Actor
async def main() -> None:
async with Actor:
# highlight-start
# Charge for a single occurence of an event
await Actor.charge(event_name='init')
# highlight-end
# Prepare some mock results
result = [
{'word': 'Lorem'},
{'word': 'Ipsum'},
{'word': 'Dolor'},
{'word': 'Sit'},
{'word': 'Amet'},
]
# highlight-start
# Shortcut for charging for each pushed dataset item
await Actor.push_data(result, 'result-item')
# highlight-end
# highlight-start
# Or you can charge for a given number of events manually
await Actor.charge(
event_name='result-item',
count=len(result),
)
# highlight-end