Issue 7095: Multiprocessing.Array(lock=False) fails - Python tracker (original) (raw)
The documentation for the Multiprocessing.Array says:
multiprocessing.Array(typecode_or_type, size_or_initializer, *, lock=True)¶
... If lock is False then access to the returned object will not be automatically protected by a lock, so it will not necessarily be “process-safe”. ...
However: In [48]: mp.Array('i',1,lock=False)
AssertionError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ multiprocessing/init.pyc in Array(typecode_or_type, size_or_initializer, **kwds) 252 ''' 253 from multiprocessing.sharedctypes import Array --> 254 return Array(typecode_or_type, size_or_initializer, **kwds) 255 256 #
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ multiprocessing/sharedctypes.pyc in Array(typecode_or_type, size_or_initializer, **kwds) 85 if lock is None: 86 lock = RLock() ---> 87 assert hasattr(lock, 'acquire') 88 return synchronized(obj, lock) 89
AssertionError:
I.e. it looks like lock=False is not actually supported.
Happens both on Python 2.6 (r26:66714, Jul 25 2009, 11:30:23) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2 and Python 2.6.1 (r261:67515, Dec 6 2008, 16:42:21) [GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin