I am using the celery task to create PDF and Excel export for user data. These tasks create temporary files. Here is the problem. I use NamedTemporaryFile objects that are automatically deleted when the file is closed. Since they are closed at the end of the task, they simply disappear immediately.
I can make it work if I set the delete property to false:
NamedTemporaryFile(delete=False)
But we have a problem to leave a bunch of temporary files in the system, which I donβt want.
I could always create a cleaning task, but I was hoping there would be a better sample ...
Thanks!
source share