2011-07-07 61 views

回答

2

在Python文档:

multiprocessing.sharedctypes.RawArray(typecode_or_type, size_or_initializer)

Return a ctypes array allocated from shared memory. 

typecode_or_type determines the type of the elements of the returned 

数组:它或者是一个ctypes类型或种类 的 一个字符类型代码由阵列模块使用。如果 size_or_initializer是一个整数然后 它确定阵列的长度, 和阵列将初始 归零。否则size_or_initializer 是一个序列,用于 对数组进行初始化,其长度为 确定数组的长度。

Note that setting and getting an element is potentially non-atomic; 

使用阵列(),而不是确保 访问使用锁定自动同步 。

所以,你可能需要使用multiprocessing.sharedctypes.Array允许进程之间的锁定和同步。

+0

谢谢。我确实在乎原子性。是否可以使用'multiprocessing.sharedctypes.Array'定义一个多维数组? – user3262424