current position:Home>Can I access UI components in Python multi process?

Can I access UI components in Python multi process?

2022-02-02 21:46:56 CSDN Q & A

I tried to access... In the process pool UI Component to modify , Like this ,ui Is the object created . The error information is below . The process pool can access UI Components ?

        func = partial(self.to_main, ui)        with ProcessPool(processes= 8) as pool:            res =, path_list)
  File "E:\PycharmProjects\", line 30, in tomain    res =, DB_path_list)  File "D:\Program Files (x86)\Python\Python37\lib\multiprocessing\", line 268, in map    return self._map_async(func, iterable, mapstar, chunksize).get()  File "D:\Program Files (x86)\Python\Python37\lib\multiprocessing\", line 657, in get    raise self._value  File "D:\Program Files (x86)\Python\Python37\lib\multiprocessing\", line 431, in _handle_tasks    put(task)  File "D:\Program Files (x86)\Python\Python37\lib\multiprocessing\", line 206, in send    self._send_bytes(_ForkingPickler.dumps(obj))  File "D:\Program Files (x86)\Python\Python37\lib\multiprocessing\", line 51, in dumps    cls(buf, protocol).dump(obj)TypeError: can't pickle mywindow objectsBackend TkAgg is interactive backend. Turning interactive mode on.

Refer to the answer 1:

Multithreaded access UI You need to use delegation
I don't know if multiple processes work

Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.

Random recommended