Sometimes, it is useful to cancel a function call when the execution time is longer than expected.
In Prefect, you can limit the execution time of a Python function call with the decorators task(timeout_seconds=n)
or flow(timeout_seconds=n)
.
If you are not aware of Prefect, checkout the getting started tutorials.