whats the best way to share string between two Python threads?
i am running a method in a second thread and i want to share some data between those threads.
# arr = Array(c_char_p, 3)
val = multiprocessing.Value(c_char)
p = multiprocessing.Process(target=process_data, args=(val,))
i want to share string between those processes. And i found articels which indicate, that i should use c_char_p for this. However i keep getting this error: "ValueError: invalid string pointer 0x02A82214"
I googled it and i found that c_char_p is a pointer which leads to problems if it is used between different threads. And instead i should use c_char (without the p) With c_char it works as long as i only have one single character. However i want to share a complete string (and i don't know exactly the length of this string)
Whats the cleanest way to do this?
If you want to know more detailed what i want to do, you can read this. Otherwise you can skip:
i want to process some data in the background and a dialog (which should run in the main thread) with a progress bar should show the progress. The progress doesn't only show a percentage but also a String-message which indicates, what exactly is done at the moment. So i have to share this string message between the two threads.
Can someone tell me what is the best way to do this?
Thanks a lot!