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

Комментарии • 38

  • @lampeve
    @lampeve Месяц назад +2

    Pleaase make the second part!!❤❤ This video was great

  • @prestonfrasch9270
    @prestonfrasch9270 2 года назад

    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!

  • @mowlanicabilla5002
    @mowlanicabilla5002 3 года назад

    This is really helpful..!! Thank you so much for uploading.!! Looking forward to the complete playlist..!

  • @mugdhabapat
    @mugdhabapat Год назад

    Good tutorial, the image processing example adds a touch of reality to it!

  • @adrishyanteemaiti6628
    @adrishyanteemaiti6628 2 года назад

    Binge-watching this video and this took me till the end! Awesome!!

  • @ankoncrete
    @ankoncrete 2 года назад

    Very helpful!!

  • @dominicldoe4838
    @dominicldoe4838 3 года назад

    Amazing video. Very clear explanation. Thanks!!

  • @sebastiansoto3595
    @sebastiansoto3595 3 года назад

    The video was awesome, thanks for sharing

  • @PrancerFrisco
    @PrancerFrisco 10 месяцев назад

    THANK YOU SO MUCH

  • @santhiyabalachandar3332
    @santhiyabalachandar3332 Год назад

    Great explanation.Thank you

  • @Fedreal_Bureau_Of_Investigaton
    @Fedreal_Bureau_Of_Investigaton 2 года назад

    You'll get big

  • @user-kj1ve8mw8l
    @user-kj1ve8mw8l Год назад

    Do you need to close the pool if it is running in a `with` block?

  • @arnabnandy2828
    @arnabnandy2828 3 года назад +1

    ❤️❤️

  • @BoxBishop
    @BoxBishop 3 года назад +3

    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?

    • @NormalizedNerd
      @NormalizedNerd  3 года назад

      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.

  • @kuimlee7772
    @kuimlee7772 Год назад +1

    if you are using the context manager, with ... as pool, then i think you don't need to do pool.close() ?

    • @NormalizedNerd
      @NormalizedNerd  Год назад +1

      Yes, you are correct. 'with' takes care of that. pool.close() is redundant here.

  • @seeker4430
    @seeker4430 7 месяцев назад

    Could you please make more videos

  • @DanielWeikert
    @DanielWeikert 3 года назад

    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

    • @NormalizedNerd
      @NormalizedNerd  3 года назад

      Please mention in which example you are having this issue.

  • @solojazz75
    @solojazz75 3 года назад

    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.

    • @NormalizedNerd
      @NormalizedNerd  3 года назад +2

      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."

  • @stydras3380
    @stydras3380 3 года назад

    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__"?

    • @NormalizedNerd
      @NormalizedNerd  3 года назад

      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.

    • @stydras3380
      @stydras3380 3 года назад

      @@NormalizedNerd Ah ok, interesting, ill try it!

  • @pritammukherjee3972
    @pritammukherjee3972 3 года назад

    Is it applicable in competitive programming?

    • @NormalizedNerd
      @NormalizedNerd  3 года назад +1

      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.

  • @sanjaykrish8719
    @sanjaykrish8719 3 года назад

    Seems ur voice is changed

    • @NormalizedNerd
      @NormalizedNerd  3 года назад +1

      Haha...this time I played with the sound a bit.

  • @indranildasgupta1760
    @indranildasgupta1760 3 года назад +1

    What happens if codeforces allow this 😂!!

  • @SlashHarkenUltra
    @SlashHarkenUltra Год назад

    Judging from RUclips, everybody in India is a programming/deep-learning expert. Is there a Hindu god of programming?

  • @elifebres466
    @elifebres466 3 года назад

    why does everyone use the exact same fucking example