Getting returned values from Processes - Intermediate Python Programming p.11

preview_player
Показать описание
Welcome to part 11 of the intermediate Python programming tutorial series. In this part, we're going to talk more about the built-in library: multiprocessing.

In the previous multiprocessing tutorial, we showed how you can spawn processes. If these processes are fine to act on their own, without communicating with eachother or back to the main program, then this is fine. These processes can also share a common database, or something like that to work together, but, many times, it will make more sense to use multiprocessing to do some processing, and then return results back to the main program. That's what we're going to cover here.

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

dear thing I always wanted to build in python and that is want to get an API or some website(scrapping) to place a calling (telephone calling) function from the python have not tried yet (I have scrapped texts alot) but if u have any suggestions whether it could be made possible through the terminal( telephone calling ) then pls give some

SwapnilSinghu
Автор

keep uploding video your videos are so cool & easy to learn

techshuter
Автор

This is useful. Thank you. Looking forward to the object oriented presentations. I'm trying to do objects in Python and they are kicking my ass. Simple classes/objects are okay but static classes, static methods and inheritance are nasty. I can do all this stuff in Java but I'm not warming to Python syntax which I find to be very cryptic.

NotMarkKnopfler
Автор

Hey sentdex!!! Love your channel, been watching your python videos for about a month now and now I found myself in a bit of a pickle. All the code from last 70 videos worked like a charm. Not this one, this one is giving me real headache. For some reason I dont get any data displayed in Python 3.6.6 window (IDLE). Code from previous video with "spawn" works just fine and displays the correct result in terminal. When I run the code covered in this video in terminal it also displays the correct result just fine. I tried almost everything I can think of, reinstalled Ubuntu and tryed again, still no go... When I try to run the same code in IDLE using Python3 on windows(also fresh install) it works both in command prompt and in IDLE. I am gobsmacked at this point.
The app I am trying to write will eventually end up beeing run on windows machine so I am not worried about it too much, but I would like to keep using Ubuntu while studying to learn a little bit about it as well. Got this "challenge accepted!!!" moment about a month ago and its still going strong thanks to you. The moment I found your Starcraft 2 videos I fell in love with this channel, so GL HF!
And if you decide to react on a long post on a 2 year old video I dont know what I will do :D

antoninvyslouzil
Автор

Hi sentdex,
Thanks for a wonderful channel. I would like your opinion on the following results.
No of cores = 4,
Problem : Making a list of [num*2 for i in range(20000)], without any explicit print or I/O operations.
Option A: Multiprocessing with processes = 4, ;Time taken is 0.15s
Option B: Normal list comprehension; Time taken = 0.003 s.
This doesn't make sense to me on why option A is so much slower. Am I missing anything obvious?

PavanKumar
Автор

What does the Pool(processes=20) do?
Does it run the function job() 20 times, or does it use 20 processes for job(), or could you have a maximum of 20 processes pass data to eachother?

wilfreddv
Автор

Is there any relation between the number of processes in the pool and the length of the list that we pass to `map`?

_adaldo
Автор

I was wondering if there’s a difference between pool and a process. In my opinion, it’s the same but maybe I’m wrong. I watched codebasics on the pool thing and he said that the input the map function takes in, it divides equally into 4 and use it to apply to the function but with the 4 cores of the CPU. And he said it was parallel process. And then it returns the output combined together as an array or a list. So if that’s the case pool is also a process?

sovanraksa
Автор

Did you ever make any test of performance using multiprocessing?. Today I had some contradictory results when I found slower performances when multiprocessing is used.

tiobraulio
Автор

what is the importance of the processes argument in Pool.cause I altered it no change in output nor in time(by timeit).

yashchavan
Автор

could you do a quick sort in which each recursive call goes to a different processor?

jonmerladet
Автор

This doesn't work anymore, does it?

noelcovarrubias
Автор

Still waiting for this OOP tutorial explaining what do all those __main__s and __init__s do :(

Автор

Does someone knows which compiler he is using?
Thanks in advance.

fabiolabarbera
welcome to shbcf.ru