我是否需要 FileLock 来读取其他批处理使用文件锁定写入的文件?

发布于 2025-01-16 00:03:01 字数 310 浏览 1 评论 0原文

我有一堆进程同时从 Python 访问和修改 csv 文件(使用 FileLock 安全地执行此操作)。我使用 Pandas 包访问该文件。

我想启动另一批进程,这些进程将访问同一个文件(读取)但不修改它。 我可以在不使用锁定系统的情况下访问该文件,并且仍然使第一个写入过程不受此影响吗?

如果可以的话,如果文件被锁定,读取文件是否必须等待写入过程完成?

我必须指出,以防不清楚,我不希望写作过程受到阅读过程的影响。然而,在我的例子中,写入过程对文件所做的修改与读取过程无关,所以我不介意它们处于写入的哪个阶段。

I have a bunch of processes accessing and modifying a csv file from Python at the same time (safely doing so with FileLock). I access the file using the Pandas package.

I would like to launch another batch of processes which are going to access this same file (reading) but without modifying it.
Can I access this file without using a locking system, and still have the first writing processes unaffected by this?

In case that it is okay to do this, will the reading of the file have to wait for a writing process to finish if it is locked?

I must note, in case that it is not clear, that I do not want the writing processes to be affected by the reading ones. However, the modifications done by the writing processes on the file are not relevant for the reading processes in my case, so I do not mind in which stage of writing they are.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文