A fargate task I have written in python 3.12 will run and complete but always complains about:
"Essential container in task exited" "Stopped | Exit code: 0"
My guess is that I need to have the task gracefully shutdown, and I have put exit(0)
but still that hasn't helped.
The logs in cloudwatch don't show any errors, just the output from a successful task.
Am I supposed to do the shutdown another way or is there something else I am missing?
I'm quite sure it's not a memory or CPU issue.
A fargate task I have written in python 3.12 will run and complete but always complains about:
"Essential container in task exited" "Stopped | Exit code: 0"
My guess is that I need to have the task gracefully shutdown, and I have put exit(0)
but still that hasn't helped.
The logs in cloudwatch don't show any errors, just the output from a successful task.
Am I supposed to do the shutdown another way or is there something else I am missing?
I'm quite sure it's not a memory or CPU issue.
Share Improve this question asked Nov 20, 2024 at 12:27 bldcavemanbldcaveman 3234 silver badges15 bronze badges 4- 1 If you expect the task to remain running (e.g., as a service), ensure your Python code doesn't exit but instead keeps the process alive, such as running a server or a loop – divyang4481 Commented Nov 20, 2024 at 12:57
- Thanks! I do actually expect it to stop for now, but just in a way that doesn't raise any errors or issues. In the future I will probably want to keep it running but I do have a few other tasks that only need to run once in a while. – bldcaveman Commented Nov 20, 2024 at 13:19
- 1 That's not really an "error" or "compliant". That is simply letting you know the container has stopped. – Mark B Commented Nov 20, 2024 at 14:21
- This was my initial belief - it just has such a naggy nature about it and looked like resources were still in use. – bldcaveman Commented Nov 20, 2024 at 18:17
1 Answer
Reset to default 2The “Essential container in task exited” message with an exit code of 0 indicates that the Fargate task completed successfully. This is expected behavior for a one-off or batch task.
If CloudWatch logs only show output and no errors, it’s a sign the task is completing as intended.
If your task is meant to run to completion (e.g., batch processing, script execution), this message is perfectly normal, and there’s nothing to worry about.