Understanding Python: Threading
Вставка
- Опубліковано 6 вер 2024
- In this video, I go over threading.
Included in the lesson is an introductory tutorial covering the basics, background, and some best practices of threading.
As always, if you have any questions or suggestions for future videos, please leave a comment down below.
Follow me on Twitter: / jakejcallahan
Source: github.com/Jac...
Timelapse music: 失望した by Eva
Link: • EVA - 失望した [Synthwave]...
Outro music: Elix by Synthness
Link: • Synthness - Elix ★ No ...
Let me know if you want me to do a deeper dive into threading in the future. Also, remember that the source code for this video, and all others in this series, can be found here: github.com/JacobCallahan/Understanding/
This is the best video for understanding python thread easily!
very useful and nice content explained very simply.
I always wanted someone to do a deep dive into the nuanced topics of Python such as how actually threads work and the GIL. Have looked around for good implementations for so long. Finally seem to have found it. Amazing work!
Thank you very much. I've considered doing a series of even deeper dives (into the implementation themselves), but too many other things to get to first.
Hi, dude. You got my subscription, thanks for sharing thoughtfully!
You are the best explainer among all the UA-camrs I've seen. 👍🏻👍🏻👍🏻
But I often have a question.
Assuming I am preparing to write a Third party API hub, which contains 10 independent external party APIs with no dependencies but finally we need to transform and append all their response in json.In this situation, would you choose to use asynchronous programming or multi-threading?
If you're not heavily depending on synchronous libraries and are comfortable with asynchronous programming, then I'd recommend async over threading.
For example, if you can use something like aiohttp to interact with those APIs, it's hard to beat async.
The downside is that it does make your design a bit more complicated, but it's a good trade-off.
Hi Jake, excellent tutorial. I absolutely love your content on youtube. It feels like a crime to be able to learn this free of cost.
Anyways, Im guessing you already know this, but we could use the python's inbuilt map method with the ThreadPoolExecutor like executor.map(func_name, list_of_args) . It just feels a bit more readable. That way we could just loop over the futures object to get the results and not use the .as_completed() method, assuming the func_name function returns something.
Cheers and Kudos!!
Thank you very much. You're definitely definitely correct that using map is anither easy way to do this, especially for those that are more used to functional programming
@@JakeCallahan Just something I realised about the map method. It returns the future objects in the order they were started and not in the order they finish. It might be helpful to someone who also cares about the order in which threads finished, incase the result is being passed on to someother function/class for which order matters.
Definitely do another video on this subject! It goes deep and you are great at explaining it!
SUPER INFORMATIVE! Thanks for the detailed dive!
When do you make the Video about Multi-Processing?
I'm planning to release it near the end of the month. I'm currently on a monthly schedule, but may sprinkle in a surprise soon as well.
Very good video
Thank you very much