Intermittent failures with tempfiles

I have a handful of tests that generate CSVs. They progressively write to a tempfile, then they generate a CSV from the data in the tempfile.

In my CircleCI builds they fail intermittently. Sometimes none, and sometimes up to 4. The failures don’t correlate with time-of-day, queue time, etc. The failures are an inability to locate the tempfile that I’ve already opened and written to in order to close it.

I was wondering if there are any sort of rules or configuration options that might limit writing to the file system.

Thanks for any direction you can give!

Have you had any progress/resolution on this?

I’m having a similar problem, except that the file I’m writing are my database settings so my database access is intermittent between test steps. It’s rather frustrating.