At the moment I face some problems sharing some data with many processes from main process.
I use multiprocess.pipe() to pass the data.
1. Initialization:-
<!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> try: global devices self.listofwritetags = self.collectwritetaglist() conn1, conn2 = multiprocessing.Pipe() devices = bussiness.initilaztion(self.comm_object,logger) conn1.send(devices) self.callmotor1dprocess = multiprocessing.Process(target=callallmotor1d,args=[conn2]) self.listofthread.append(self.callmotor1dprocess) <!-- end snippet -->

2.Start and stop process:-
<!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> def startprocess(self): for item in self.listofprocess: item.start() def stopprocess(self): for item in self.listofprocess: item.terminate() <!-- end snippet -->

UI:-
<!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> self.button3 = ttk.Button(self.frame, text='Start', command=self.startprocess,state =NORMAL) self.button3.grid(column=1, row=4, sticky=W,padx=5, pady=5) self.button4 = ttk.Button(self.frame, text='Stop', command=self.stopprocess, state=NORMAL) self.button4.grid(column=1, row=5, sticky=W, padx=5, pady=5) <!-- end snippet -->

I need to call avobe 3 process in one class:- FormUI
but I call executable process outside of the FormUI class.
I got an error when I try to initialize.I want to pass devices from main process to child process.
The calling method:-
<!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> def callallmotor1d(conn): devices = conn.recv() bussiness.motorallprocessing(devices) def callallsov1s(conn): devices = conn.recv() bussiness.motorallprocessing(devices) <!-- end snippet -->

Any help regarding this would be appreciable
Error messege:-
2019-09-03 13:15:33,755: can't pickle _thread.lock objects
Traceback (most recent call last):
File "C:/Users/misu01/PycharmProjects/opcua/ui_v7.py", line 226, in initilization
conn1.send(devices)
File "C:\Users\misu01\AppData\Local\Programs\Python\Python37\lib\multiprocessing\connection.py", line 206, in send
self._send_bytes(_ForkingPickler.dumps(obj))
File "C:\Users\misu01\AppData\Local\Programs\Python\Python37\lib\multiprocessing\reduction.py", line 51, in dumps
cls(buf, protocol).dump(obj)
TypeError: can't pickle _thread.lock objects
This post has been edited by modi123_1: 03 September 2019 - 09:12 AM
Reason for edit:: In the future, please use the [code] tag button in the editor.