Python os.path.isfile returns the wrong answer if I create a file right after that

127 Views Asked by At

I'm totally confused, I'm using os.path.isfile a line before a create a file, sth like this

assert not os.path.isfile(file), "file exists"
pd_df.to_csv(file)

and surprisingly it returns an exception, but if I add a 5 sec delay in between it will work. This is total nonsense to me since this is not a parallel programming, why is this happening?

0

There are 0 best solutions below