[英]Is it possible for multiple processes to simultaneously only read (not write to) from a file in Python?
I have spawned multiple processes using multiprocessing.Process in a loop and each process is trying to read the same file.我在一个循环中使用 multiprocessing.Process 生成了多个进程,并且每个进程都试图读取同一个文件。 Will this cause an issue?这会引起问题吗? References to the answers are most welcome.非常欢迎参考答案。
It's no problem.没问题。 Not only applies to files, also to RAM.不仅适用于文件,也适用于 RAM。 You only get in trouble when someone is writing.只有当有人在写作时,你才会遇到麻烦。
The phenomenon is called a data race (emphasis mine):这种现象被称为数据竞赛(强调我的):
access [==read] a memory location at the same time that a memory operation in another thread is writing to that memory location访问[==read] 一个 memory 位置,同时另一个线程中的 memory 操作正在写入该 memory 位置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.