apify / apify-sdk-python

The Apify SDK for Python is the official library for creating Apify Actors in Python. It provides useful features like actor lifecycle management, local storage emulation, and actor event handling.
https://docs.apify.com/sdk/python
Apache License 2.0
115 stars 11 forks source link

Correctly handle actor exit #200

Closed janbuchar closed 3 months ago

janbuchar commented 3 months ago

Originally reported in https://apify.slack.com/archives/CGZSN9DQC/p1715957828029029.

The user spawned an asyncio task in the actor. When the actor finished (reached the end of the Actor context manager block), it didn't clean up the task and the container was left there hanging.

We should either cancel all tasks when the actor is exitting or just trigger a sys.exit after a certain timeout.

Relevant code and JS counterpart

B4nan commented 3 months ago

we should put priority on this one, at least implement the configurable timeout after which we kill the process completely, we can leave the wait for bound events (via actor.on) for later if it would be too time consuming.