PaulCCCCCCH/Robustar_implementation

Enhance exception handling in `upload_model` API for clean-up of temporary files

Closed this issue · 0 comments

In our upload_model API, we handle expected exceptions by cleaning up temporary files (code and weights) and aborting the business logic. However, we've encountered a challenge with unexpected exceptions: they don't trigger the clean-up process. While we've considered an outermost try...except block, this interferes with the abort operation initiated by expected exceptions.

We're looking for a solution that ensures the deletion of temporary files in all exception scenarios without disrupting our existing exception handling logic. One possible solution is implementing a context manager, similar to the with statement in Python for resource management (as discussed in this StackOverflow thread).