Python Tutorial 34: Multiprocessing

preview_player
Показать описание
In this video, you will learn about multiprocessing in Python. We will first explain what multiprocessing is and how it works on computers. Then we will write code with and without multithreading and compare how fast it runs. Finally, we will compare multiprocessing with multithreading. This is the 34th video in a series of Python Tutorials. This course will teach you how to go from beginner to independent programmer. If you like this video make sure to subscribe and ring the bell so that you’ll be up to date with the latest Python material!

Timestamps:
0:00 Welcome
0:13 What is Multiprocessing
0:55 Code Before Multiprocessing
2:19 Code with Multiprocessing
5:10 Multiprocessing vs Multithreading

Рекомендации по теме
Комментарии
Автор

This was great, keep up the good work!

empowercode
Автор

Any thoughts how to run a PyQt GUI in its own process?

I've tried using a multiprocessing class,
import multiprocessing as mp
class MpClass(mp.Process):
def _init_ (self, pipe, signal):
self.signal = signal
def run (self):
while True:
self.signal.emit("Hello") #send signal to GUI to update

However, instantiating a Gui object, that instantiates the mp object, leads to pickle errors and/or the Signal/Slot can't be reached!
class
authenticated = QtCore.pyqtSignal ( str )
self.authenticated.connect ( self.callback )
...
def _init_ (self, pipe):
proc1 = MpClass(self.pipe, authenticated)
proc1.start()
def callback (self, strval):
print ("World")

pipe = multiprocessing.Pipe()
GuiMainClass (pipe)

Or would PyQt work better with multithreading instead.. qthread?

bennguyen
welcome to shbcf.ru