[issue3206] Multiprocessing Array and sharedctypes.Array error in docs/implementation

Santiago Gala report at bugs.python.org
Sat Dec 6 14:24:45 CET 2008


Santiago Gala <sgala at apache.org> added the comment:

Note that if the error is in the documentation semantics, and not in the
implementation, then the benchmark code in the documentation is also
broken, and should be change to not use lock=True/False respectively...

I'm not sure if the patch here is good or rather lock=True/False should
be the right API and the implementation should be changed along this lines:

diff --git a/Lib/multiprocessing/sharedctypes.py
b/Lib/multiprocessing/sharedctypes.py
index b94cd52..2f68e74 100644
--- a/Lib/multiprocessing/sharedctypes.py
+++ b/Lib/multiprocessing/sharedctypes.py
@@ -79,10 +79,11 @@ def Array(typecode_or_type, size_or_initializer,
**kwds):
     if kwds:
         raise ValueError('unrecognized keyword argument(s): %s' %
list(kwds.keys()))
     obj = RawArray(typecode_or_type, size_or_initializer)
-    if lock is None:
+    if lock is True:
         lock = RLock()
-    assert hasattr(lock, 'acquire')
-    return synchronized(obj, lock)
+        return synchronized(obj, lock)
+    return obj
+    
 
 def copy(obj):
     new_obj = _new_value(type(obj))

----------
nosy: +sgala

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3206>
_______________________________________


More information about the Python-bugs-list mailing list