ml-study icon indicating copy to clipboard operation
ml-study copied to clipboard

Question out of curiosity about multi-threading/multi-processing

Open MatthiVH opened this issue 6 years ago • 0 comments

Dear Mr. Fortuner,

I am Matthias, a researcher from Ghent University in Belgium and I had a small question about some of your code. When I was programming in Python last week, I found your article 'Intro to Threads and Processes in Python'(1) on the internet. First of all, thanks a lot for sharing that, I have to say that it's very clear and interesting and I'll probably use the code for some research in the future.

But I had a small question about it. When looking at the graphs, I would love to have the threads visualized by a single color so that you can easily see which tasks were executed by which thread.

Looking a bit more into how to apply this to your code, this could probably be done by adding an extra return variable to the function 'download' that says: a = str(threading.current_thread().ident). By having the id's of each thread, you could then assign a color to each different id-number and use this list of colors as input for the visualization. So what I was wondering is how to add an extra return variable to the 'download'-function. Now it says 'return start,stop' and I would like to have 'return start, stop, a' for example, so that the 'a' can return the id's of the threads.

But when editing the code to include this extra variable, I got nothing but errors in the parts that use the return values of the function 'download' and therefore I was kind of hoping that you maybe could give me some clues to make this happen since you know the code the best and know where you need to add what to have no conflicts. If it finally works I can push it even to the directory as an extra feature if you want.

Kind regards, Matthias Van Hove

(1) https://medium.com/@bfortuner/python-multithreading-vs-multiprocessing-73072ce5600b

MatthiVH avatar Oct 15 '19 00:10 MatthiVH