New submission from Andrii V. Mishkovskyi <[EMAIL PROTECTED]>: multiprocessing.sharedctypes.Array and multiprocessing.sharedctypes.Value if used according to documentation fail with AssertionError.
Python 3.0b1+ (py3k:64518, Jun 25 2008, 12:52:38) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from multiprocessing import sharedctypes >>> sharedctypes.Array('i', 1, lock=True) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.0/multiprocessing/sharedctypes.py", line 88, in Array assert hasattr(lock, 'acquire') AssertionError >>> sharedctypes.Array('i', 1, lock=False) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.0/multiprocessing/sharedctypes.py", line 88, in Array assert hasattr(lock, 'acquire') AssertionError >>> sharedctypes.Array('i', 1, lock=None) <SynchronizedArray wrapper for <multiprocessing.sharedctypes.c_long_Array_1 object at 0x83214f4>> >>> Value('i', lock=True) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.0/multiprocessing/__init__.py", line 246, in Value return Value(typecode_or_type, *args, **kwds) File "/usr/local/lib/python3.0/multiprocessing/sharedctypes.py", line 75, in Value assert hasattr(lock, 'acquire') AssertionError The same goes for multiprocessing.Array and multiprocessing.Value. Comparing code to documentation it's obvious that lock argument can be one of Lock, RLock or None objects (or any object with "acquire" attribute), but not True or False. Also, looking at the code it seems strange to me that 'lock' is a keyword-only argument. Why not use simple default argument "lock=None" for Array() function? Proposed patch tries to address these issues. ---------- components: Library (Lib) messages: 68771 nosy: jnoller, mishok13, roudkerk severity: normal status: open title: Multiprocessing Array and sharedctypes.Array error in docs/implementation versions: Python 3.0 _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3206> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com