other-emerald•12h ago
i try gracefull abort : show this log
i try gracefull abort : show this log but abort_handler function not fire

2 Replies
Let's move to thread so we don't spam the channel. Please copy your code here
conscious-sapphire•11h ago
async def abort_handler(event_data):
# Called when ABORTING event occurs
Actor.log.info(">>> Aborting: do cleanup and save state here.")
# For example: save state
await Actor.set_value("partial_state", {"progress": 123})
# Optionally exit
await Actor.exit(status_message="Aborted by user, cleaned up", exit_code=0)
async def main() -> None:
"""
The main coroutine is being executed using
# Register the abort handler Actor.on(Event.ABORTING, abort_handler) this is code @Lukas Krivka @Lukas Krivka let me know for this issue
asyncio.run()
, so do not attempt to make a normal function
out of it, it will not work. Asynchronous execution is required for communication with Apify platform,
and it also enhances performance in the field of web scraping significantly.
"""
async with Actor:
# Read the Actor input
actor_input = await Actor.get_input() or {}
Keyword_val = actor_input.get('Keyword')
# Register the abort handler Actor.on(Event.ABORTING, abort_handler) this is code @Lukas Krivka @Lukas Krivka let me know for this issue