homepage

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.

Author bred
Recipients bred
Date 2012年09月10日.09:59:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1347271179.81.0.646236436369.issue15901@psf.upfronthosting.co.za>
In-reply-to
Content
I've simply tested the example reported in the py3k documentation, and it don't works.
See the site:
http://docs.python.org/py3k/library/multiprocessing.html?highlight=multiprocessing#module-multiprocessing.sharedctypes
The program exit with this error:
> python sha.py
Traceback (most recent call last):
 File "sha.py", line 21, in <module>
 s = Array('c', 'hello world', lock=lock)
 File "/usr/lib/python3.2/multiprocessing/sharedctypes.py", line 112, in Array
 obj = RawArray(typecode_or_type, size_or_initializer)
 File "/usr/lib/python3.2/multiprocessing/sharedctypes.py", line 89, in RawArray
 result.__init__(*size_or_initializer)
TypeError: one character string expected
Observe that the following code works correctly with python2!
I'm using python 3.2.3 and gcc 4.7.1 under ArchLinx 
 
Te code is:
http://docs.python.org/py3k/library/multiprocessing.html?highlight=multiprocessing#module-multiprocessing.sharedctypes
####################################################################
from multiprocessing import Process, Lock
from multiprocessing.sharedctypes import Value, Array
from ctypes import Structure, c_double
class Point(Structure):
 _fields_ = [('x', c_double), ('y', c_double)]
def modify(n, x, s, A):
 n.value **= 2
 x.value **= 2
 s.value = s.value.upper()
 for a in A:
 a.x **= 2
 a.y **= 2
if __name__ == '__main__':
 lock = Lock()
 n = Value('i', 7)
 x = Value(c_double, 1.0/3.0, lock=False)
 s = Array('c', 'hello world', lock=lock)
 A = Array(Point, [(1.875,-6.25), (-5.75,2.0), (2.375,9.5)], lock=lock)
 p = Process(target=modify, args=(n, x, s, A))
 p.start()
 p.join()
 print((n.value))
 print((x.value))
 print((s.value))
 print([(a.x, a.y) for a in A])
History
Date User Action Args
2012年09月10日 09:59:39bredsetrecipients: + bred
2012年09月10日 09:59:39bredsetmessageid: <1347271179.81.0.646236436369.issue15901@psf.upfronthosting.co.za>
2012年09月10日 09:59:39bredlinkissue15901 messages
2012年09月10日 09:59:39bredcreate

AltStyle によって変換されたページ (->オリジナル) /