简体   繁体   中英

Does multiprocessing.shared_memory require locking?

I'm learning about shared memory in Python, especially the python 3.8 module multiprocessing.shared_memory . I see no mention of locking in the documentation. (Although the parent module, multiprocessing , has a Lock object). Are locks somehow handled in the underlying code of multiprocessing.shared_memory or in /dev/shm ? That is, is it safe to write to a SharedMemory object from multiple processes at the same time with no explicit locking? Thank you advance for any clarification.

https://docs.python.org/3/library/multiprocessing.shared_memory.html

The Array() class is supposed to be like the synchronized version of shared memory, so no I expect not. You get what it says: a block of shared memory with no synchronization overhead, for times when you don't need it or want to implement your own.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM