This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Multiprocessing.Array(lock=False) fails
Type: behavior Stage:
Components: Extension Modules Versions: Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: jnoller Nosy List: ggenellina, jnoller, schlesin
Priority: normal Keywords:

Created on 2009-10-09 23:13 by schlesin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg93812 - (view) Author: schlesin (schlesin) Date: 2009-10-09 23:13
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.
msg93813 - (view) Author: Jesse Noller (jnoller) * (Python committer) Date: 2009-10-09 23:53
schlesin - what platform are you on, and what version of 2.6?
msg93814 - (view) Author: schlesin (schlesin) Date: 2009-10-10 00:12
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
msg93817 - (view) Author: Gabriel Genellina (ggenellina) Date: 2009-10-10 02:40
Fixed in r68708 - upgrading to 2.6.2 should solve this.
msg93819 - (view) Author: Jesse Noller (jnoller) * (Python committer) Date: 2009-10-10 02:58
Gabriel is right, I'm really hoping Apple includes an upgrade including 
2.6.4 once it's buttoned down
History
Date User Action Args
2022-04-11 14:56:53adminsetgithub: 51344
2009-10-10 02:58:41jnollersetstatus: open -> closed
resolution: duplicate
2009-10-10 02:58:26jnollersetmessages: + msg93819
2009-10-10 02:40:27ggenellinasetnosy: + ggenellina
messages: + msg93817
2009-10-10 00:12:16schlesinsetmessages: + msg93814
2009-10-09 23:53:00jnollersetmessages: + msg93813
2009-10-09 23:47:47benjamin.petersonsetassignee: jnoller

nosy: + jnoller
2009-10-09 23:13:17schlesincreate