The answer here may not answer the question. The problem is due to fork()
. From the example, you seemed want to share data between two Python scripts. Let me explain my view.
As of Python 3.8, there is no true Unix's fork()
implementation in Windows platform. For the example above to work, a child process must inherit all environment and open file descriptors.
I understand that Windows now support Windows Linux Subsystem, but the last i checked it still does not fully implement fork. Cygwin does actually but it is a bit slow.
I do not know how, until now, to pass information between two Python scripts using mmap in Windows platform. Use
multiprocessing.Queue
or
multiprocessing.Pipe
or
multiprocessing.Manager
or
multiprocessing
's shared memory (Value
and Array
) instead.
I believe you could make each Python script to read in content of the to-be-mapped file into Array
of characters. Then use your own structure to map the shared memory into a structured data as you do for the to-be-mapped file.