Python Tutorial - how to use multiprocessing to run multiple functions at the same time

preview_player
Показать описание
Python Tutorial - how to use multiprocessing to run multiple functions at the same time. This tutorial will show you how to run your python code a-synchronously. This means that you will be able to run multiple functions at the same time.

I would like to thank all of you, for the support that you have showed me in all my recent videos. I am very grateful for it. If you guys have any ideas for future videos make sure to post them in the community tab under my post "ideas for next videos". And as always guys I will see your beautiful faces in the next tutorial.

Join the discord channel to have some fun:

Follow me on instagram:

*** Music Credits ***

Checkout my setup!!!

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

Nice vid and very much liked the accuracy of using __main__ to stop the spawned processes recursively generating infinite processes. It's a subtlety that is easily overlooked.

KevCon
Автор

Great Video Sir … very well explained …. I wish I had seen this video a few weeks back. Now I understand that if __name__ == “__main__” is vital to multiprocessing. Now I understand. Thanks a ton Sir ❤❤❤

brpawankumariyengar
Автор

Awesome video, I was looking for a tutorial for this.

omarsplaytimechannel
Автор

thank you, you just saved me a two day headache.

hanzohattori
Автор

Absolutely amazing, cannot wait to try it!

martinmehaudy
Автор

How many processes can you have running at the same time? Also, what exactly is the purpose of having the __main__ thing?

GCarrot
Автор

hey! multiprocessing don't work when compiled to an .exe file so if you want multiprocessing in an executable file you should use threading library

afonsojeronimo
Автор

Hello Johan. How about you want to store the value you produced when you run the functions. How do I code that one?

jasperescuro
Автор

This is cool, but I can’t find a good way to be able to actually get the return value of the function, just execute it.

maxp
Автор

why i copy whole code and 'finish' returns 64734.0125234 seconds instead of 0.5 or 1 or just regular values?

maciejbukalski
Автор

Hi sir it was useful, thanks a lot. Can I ask a question, how to write a parallel program for spell checking in python

ahmadsalihy
Автор

I thought this would work for my script, but unfortunately I'm having trouble returning the values I need from my functions which run in parallel. My functions don't return integers or floats, but pandas dataframes (2 dataframes in fact). I unfortunately have not found a way to return these dataframes. Would you know how to return complex objects using the multiprocessing method?

UpdatE: nvm your second video fixed my problem. Thank you so much!!! Subscribed and liked for your help <3 <3

shooby
Автор

What's the difference between multiprocessing and multithreading?

Kig_Ama
Автор

AttributeError: partially initialized module 'multiprocessing' has no attribute 'Process' (most likely due to a circular import)

i'm using pycharm & python 3.8

klziqxb
Автор

Is it possible to take 2 say 200 line codes into one, because when I just try to copy and paste it into one on visual studies, one of them darkens

thiccduck
Автор

@8:23 my time "Finished running after seconds:" is always above 2 seconds, the first two prints are almost identical, just the last print from multiprocessing is always above 2 seconds, any ideas why?

antonmataj
Автор

Awesome explanation bro, I have a question... If u create 10 different scripts(without using multiprocessing) and run them at the same time, will they run on a single core or be distributed on all the cores available?

AlgoCoder
Автор

I'm waiting it. I like the video even before it's published. Because i know Who made it, there's no way for it to be bad.

weeg
Автор

Hi there, Great video. I have a little question. I have a program that has a while loop and a for loop. I want to run them simultaneously. Do you how I can do that

kkanyetrump
Автор

Great content!!! I have a question that needs ur kind help. I am using python multiprocessing module to write data out to multiple files at the same time to speed up the writing process. But the output files end up having mixed data. For example, I want to write dict[1] to file1.txt, dict[2] to file2.txt, But the problem is file2.txt has some data that was supposed to be in file1.txt. Any knowledge on why this could happen?
i have been googling for a while but the only potential evidence is that someone mentioned the file writting is not thread safe, so some data could be flying between different process of writting. Any knowledge on this? I would really appreciate ur kind help!

tianliu