use portalocker to lock files rather than relying on os.fileexists