use os.rename can be atomically