Multiprocessing in Python | Basics to Advanced | Tutorial - 1
HTML-код
- Опубликовано: 3 июл 2024
- In this video, I'll explain the concept of multiprocessing and how to implement multiprocessing in Python3 with multiple real-world scenarios!
#python #programming
Chapters
0:00 Introduction
0:35 Concept
3:56 Example 1 basic code
9:05 Example 2 prime checking
15:21 Example 3 image downloader
Like my work? Support me -
www.buymeacoffee.com/normaliz...
For more videos please subscribe -
bit.ly/normalizedNERD
Source code -
github.com/Suji04/NormalizedN...
Facebook -
/ nerdywits
Instagram -
/ normalizednerd
Twitter -
/ normalized_nerd
Pleaase make the second part!!❤❤ This video was great
This was great! I was really glad when you explained how to add more function arguments through the functools library "partial()" function at the end. Thanks for taking the time to do this! This is for an NLP project with about 80 files each delivery, so I think it will really help!
This is really helpful..!! Thank you so much for uploading.!! Looking forward to the complete playlist..!
Good tutorial, the image processing example adds a touch of reality to it!
Binge-watching this video and this took me till the end! Awesome!!
Woo...thanks a lot!!
Very helpful!!
Amazing video. Very clear explanation. Thanks!!
Great to hear!
The video was awesome, thanks for sharing
My pleasure!
THANK YOU SO MUCH
Great explanation.Thank you
You are welcome!
You'll get big
Do you need to close the pool if it is running in a `with` block?
❤️❤️
😍😍
really good video my friend, straight to the point with simple explanation. I couldn't believe how easy it all looked when you explained it. I have question in another topic for you, perhaps you could help - I'm trying to write something similar to pygame module (basicly i want pygame cube example functionality in program (displaying x's and y's of points)), is there anyway you could recommend something that I could use? Should I try to create my own graphics engine?
Thanks!
I'm not very familiar with pygame but if you only want to render some nice animations then Manim would work. You can also check out p5.js.
if you are using the context manager, with ... as pool, then i think you don't need to do pool.close() ?
Yes, you are correct. 'with' takes care of that. pool.close() is redundant here.
Could you please make more videos
what if the function should print something. I can see the code run faster without error but only the time delta is printed. Nothing inside the function itself. With "standard" way it works normal
any ideas
Please mention in which example you are having this issue.
Thanks for the video, can you eli5 why linux users dont have to create the __main__ block? Is it true for mac users too? I am curious.
I'm quoting a great comment from a reddit user.
"Python’s multiprocessing package offers two methods for creating new processes: spawn and fork, with spawn being the only option on Windows. The essential difference between them is that when using spawn, the child process reimports the current module from which it was created, but fork doesn’t. But, when you import a module in Python (say, “mymodule”), you’re actually executing the file “mymodule.py”, but not as __main__ (that if block doesn’t get run). Hence if your multiprocessing code is outside the __main__ conditional, you run into a situation where any spawned process is subsequently attempting to spawn more processes, which then spawn more processes, and so on. Rightfully, the Python interpreter detects this and halts-you can try it out yourself."
Thanks for the video! I have a small question: What am I supposed to do when wanting to use multiprocessing in a submodule, where I then cant use __name__=="__main__"?
Very simple...write the multiprocessing code in the submodule (without the main block). Then in your driver script (where you are gonna call the functions of other modules) use the main block. This way, you are using the main block only once. Just make sure that every function call is happening inside this main block.
@@NormalizedNerd Ah ok, interesting, ill try it!
Is it applicable in competitive programming?
Unfortunately no. Some platforms don't even support multiprocessing module. And in the rest, it wouldn't actually reduce the time because there's an overhead of creating multiple processes.
Seems ur voice is changed
Haha...this time I played with the sound a bit.
What happens if codeforces allow this 😂!!
Haha XD
Judging from RUclips, everybody in India is a programming/deep-learning expert. Is there a Hindu god of programming?
why does everyone use the exact same fucking example