The Runpod SDK’sDocumentation Index
Fetch the complete documentation index at: https://runpod-b18f5ded-promptless-remove-flash-beta-notification.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
clean() function helps maintain the health of your Serverless worker by removing temporary files and folders after processing completes. This is particularly important for workers that download large assets or generate temporary artifacts, as accumulated data can lead to DiskQuotaExceeded errors over time.
Import the clean() function
To use the clean() function, import it from the utils.rp_cleanup module:
Default behavior
When called without arguments,clean() targets a specific set of default directories for removal:
input_objects/output_objects/job_files/output.zip
Custom cleanup
If your handler generates files in non-standard directories, you can override the default behavior by passing a list of folder names to thefolder_list parameter.
Use clean() in your handler
You should integrate cleanup logic into your handler’s lifecycle, typically within a finally block or right before returning the result.
Best practices
To ensure reliability, always callclean() at the end of your handler execution. We recommend wrapping your cleanup calls in a try...except or finally block so that disk space is recovered even if your main processing logic fails.
Be cautious when adding custom folders to the cleanup list to avoid accidentally deleting persistent data, and consider logging cleanup actions during development to verify that the correct paths are being targeted.