python - Force multiprocessing.Array to be created in memory instead of on disk -
i using python 3.4 on linux. want create array in ram shared processes spawned multiprocessing
module (i.e. shared memory). according documentation, should possible using multiprocessing.array
. when use
array = multiprocessing.array('i', n)
python creates file in /tmp
, zeroes it, , uses through mmap.mmap()
shared memory (i have verified looking /usr/lib/python3.4/multiprocessing/heap.py
). however, array created in memory, not on disk. reason in use case, n
large (more 100 gb), have lot of ram low disk capacity. creation of multiprocessing.array()
ends ioerror: no space left on device
because uses file on disk shared memory rather ram.
i able around mounting directory via tmpfs
, setting tempfile.tempdir
point directory. however, there easier way? why python creating shared memory in way?
the short answer no. long answer, read this:
you can use os.fork() pass copy of parent's memory child can't share address space.
Comments
Post a Comment