Python : Race condition of type TOCTOU