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 magu
Recipients ezio.melotti, magu, vstinner
Date 2017-12-12.17:00:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513098036.37.0.213398074469.issue32291@psf.upfronthosting.co.za>
In-reply-to
Content
It seems like sharing a string over processes is not possible.

	#!/usr/bin/env python3
	
	import multiprocessing
	import threading
	import ctypes
	
	
	def fun(share_c, share_s, set_c, set_s, name):
		print(f'{name}: {share_c.value}; {share_s.value}')
		share_c.value = set_c
		share_s.value = set_s
		print(f'{name}: {share_c.value}; {share_s.value}')
	
	
	if __name__ == '__main__':
		share_c = multiprocessing.Value(ctypes.c_wchar, 'a')
		share_s = multiprocessing.Value(ctypes.c_wchar_p, 'aa')
	
		print(f'pre_thread: {share_c.value}; {share_s.value}')
		thread = threading.Thread(target=fun, args=(share_c, share_s, 'b', 'bb', 'thread'))
		thread.start()
		thread.join()
	
		print(f'post_thread: {share_c.value}; {share_s.value}')
		process = multiprocessing.Process(target=fun, args=(share_c, share_s, 'c', 'cc', 'process'))
		process.start()
		process.join()
	
		print(f'post_process: {share_c.value}', end='; ')
		print(share_s.value)  # <--- Blows here

produces: 

	pre_thread: a; aa
	thread: a; aa
	thread: b; bb
	post_thread: b; bb
	process: b; bb
	process: c; cc
	post_process: c; Traceback (most recent call last):
	  File "test2.py", line 30, in <module>
	    print(share_s.value)  # <--- Blows here
	  File "<string>", line 5, in getvalue
	ValueError: character U+ff92f210 is not in range [U+0000; U+10ffff]

Where the character value in the error message is different every time. To me this seems like a bug as it is working properly with threads as well as single characters. (Maybe relevant question also here: https://stackoverflow.com/questions/47763878/how-to-share-string-between-processes?noredirect=1#comment82492062_47763878)

For the case it matters:
Python 3.6.1 (Anaconda 4.4.0) on RHEL 6
History
Date User Action Args
2017-12-12 17:00:36magusetrecipients: + magu, vstinner, ezio.melotti
2017-12-12 17:00:36magusetmessageid: <1513098036.37.0.213398074469.issue32291@psf.upfronthosting.co.za>
2017-12-12 17:00:36magulinkissue32291 messages
2017-12-12 17:00:36magucreate