Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to sharing object between multiple process from main process using Pipe
#1
I try to call multiprocessing to act my process faster.
At the moment I face some problems sharing some data with many processes from main process.
I use multiprocess.pipe() to pass the data.

I use multiprocess.manager to pass the data.

1. Initialization:-



<

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)





2.Start and stop process:-



def startprocess(self):
for item in self.listofprocess:
item.start()


def stopprocess(self):
for item in self.listofprocess:
item.terminate()



UI:-




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)



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:-





def callallmotor1d(conn):
devices = conn.recv()
bussiness.motorallprocessing(devices)



def callallsov1s(conn):
devices = conn.recv()
bussiness.motorallprocessing(devices)





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
Larz60+ wrote Sep-03-2019, 04:01 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. Refer to BBCode help topic on how. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Quote
#2
self.listofprocess has not been declared anywhere in the code you posted
def startprocess(self):
    for item in self.listofprocess:
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  process finished with exit code -1073741819 (0xC0000005) GMCobraz 8 493 Sep-01-2020, 08:19 AM
Last Post: GMCobraz
  Sharing X Axis in Sub plots JoeDainton123 1 177 Aug-22-2020, 04:11 AM
Last Post: deanhystad
  Get stdout of a running process yok0 0 214 Aug-20-2020, 10:12 AM
Last Post: yok0
  Defining multiple functions in the same def process sparkt 5 238 Aug-09-2020, 06:19 PM
Last Post: sparkt
  Files to store configuration and steps for a industrial process control application Danieru 1 242 Aug-03-2020, 05:43 PM
Last Post: buran
  STT: recognition connection failed: [Errno 32] Broken pipe GrahamBerends 0 302 Jul-18-2020, 11:00 PM
Last Post: GrahamBerends
  Wait for command within a process bRitch022 1 187 Jul-15-2020, 07:03 PM
Last Post: bRitch022
  How to to tie the execution of one process to another inside a loop in Python ignorant_wanderer 0 220 Jul-11-2020, 03:44 AM
Last Post: ignorant_wanderer
  How to pass a list by value for manipulation within a process? bRitch022 4 370 Jul-09-2020, 07:13 PM
Last Post: bRitch022
  Automate process _ 2 cvs files Python_Fatli 1 183 Jul-05-2020, 09:42 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)