Код: Выделить всё
shared_queue = multiprocessing.Queue()
class MyProcess:
def foo(self, nb):
pid = os.getpid()
output = f"Process id = {pid}\nReceived nb = {nb}"
shared_queue.put(output)
print(output)
def do_stuff(self):
pool_size = 8
p = Pool(pool_size)
p.map(self.foo, range(pool_size))
< /code>
Я заменил функцию загрузки FTP на меньшую печать, но я получаю одинаковую проблему с обоими.from other_module import MyProcess, shared_queue
class MyThread(QThread):
my_sig = Signal(str)
def run(self):
while True:
text = shared_queue.get(block=True)
self.my_sig.emit(text)
class Window(QWidget):
def __init__(self):
# setting up a
# window with a label
# and a button
self.thread = MyThread()
self.thread.my_sig.connect(self.update_label)
self.thread.start
self.button.clicked.connect(self.button_handler)
def update_label(self, text):
self.label.setText(text)
print(text)
self.label.update()
QApplication.processEvents()
def button_handler(self):
bar = MyProcess
bar.do_stuff()
Подробнее здесь: https://stackoverflow.com/questions/796 ... ol-pyside6