Closed diego-lima closed 9 months ago
Hi @diego-lima, thanks for opening your first issue with Prefect. I was able to reproduce this using a simpler example:
from prefect import flow
@flow(retries=5)
def my_flow():
raise ValueError("This is a test")
if __name__ == "__main__":
my_flow.serve(name="my-first-deployment")
We have added this to our backlog to work on as soon as we can.
FWIW, I was able to produce with @diego-lima's code with Prefect 2.14.5 but not with @serinamarie's code. I ran with the process limit set to 5 and 1.
Result from @serinamarie's example:
...
ValueError: This is a test
11:31:29.277 | ERROR | Flow run 'hilarious-mosquito' - Finished in state Failed('Flow run encountered an exception. ValueError: This is a test')
11:31:29.565 | INFO | prefect.flow_runs.runner - Process for flow run 'hilarious-mosquito' exited cleanly.
First check
Bug summary
There's a process limit setting (
PREFECT_RUNNER_PROCESS_LIMIT
) that doesn't allow more than a certain number of subprocesses running at a time.Currently, it's easy to reach this limit while trying out the official Tasks tutorial and when this happens, the python process crashes with
RuntimeError: this borrower is already holding one of this CapacityLimiter's tokens
.This is bad developer experience because I had to keep paying attention to my script and restarting it when it died. As a workaround I wrapped the
serve()
call in an infinite loop.I could increase the process limit, but there's no guarantee I'll never reach it so I'd have to keep checking if my script hasn't died. If I run into that limit at any point, I think I shouldn't have to restart my script.
Apparently the default value is
5
(ref: slack) and I ran into this issue by running the tutorial example (snippet attached) with an input I knew would error (e.g:repo_name="asasdasd"
) and set retry to some number (e.g.5
)Reproduction
Error
Versions
Additional context
No response