Python Multithreading Tutorial #1 - What is a Thread?

  Рет қаралды 38,370

Tech With Tim

Tech With Tim

Күн бұрын

Пікірлер: 33
@FeedFall8
@FeedFall8 5 жыл бұрын
this video helped me reduce lag in my applications that have over 250,000 objects
@anonjr7585
@anonjr7585 5 жыл бұрын
nice video man, i was unable to understand at beginning when i looked at the code, but then i understood evrything after your illustrations.
@TechWithTim
@TechWithTim 5 жыл бұрын
Awesome! Glad to hear that :)
@elishashmalo3731
@elishashmalo3731 5 жыл бұрын
PLEASE DO MORE PYTHON PROBLEMS AND SOLUTIONS!! Like one a week?
@TechWithTim
@TechWithTim 5 жыл бұрын
Possibly!
@willgiovanni2041
@willgiovanni2041 3 жыл бұрын
Pro trick: you can watch series at flixzone. Me and my gf have been using them for watching lots of of movies lately.
@upasanadhameliya9911
@upasanadhameliya9911 3 жыл бұрын
Awesome tutorial dude! You're really talented :))
@FeedFall8
@FeedFall8 5 жыл бұрын
also Great video As usual Tim :)
@DanielWeikert
@DanielWeikert 5 жыл бұрын
Is there any priority? Lets say thread 1 sleeps so thread 2 starts and takes 5 minutes without a break to finish. thread 1 (half executed) would then have to wait 5 minutes until it resumes and finishes then?
@TechWithTim
@TechWithTim 5 жыл бұрын
good question, yes you would have to wait. There is ways around this however...
@DanielWeikert
@DanielWeikert 5 жыл бұрын
@@TechWithTim thanks Tim
@chujuntang3517
@chujuntang3517 5 жыл бұрын
I think thread priority is not controllable in Python due to unawareness of GIL to switch thread.
@baruchba7503
@baruchba7503 5 жыл бұрын
If it's possible to show msec in the clock time this may be a better demonstration to show how the threads wait and start.
@devpatel6319
@devpatel6319 4 жыл бұрын
Perfect explanation .. keep it up 👻👍👍👌
@arshia.sasson
@arshia.sasson 4 жыл бұрын
I am looking into making a device manager that would interact with several comports (at least 2-3, but could be as many as 6) that would read logs/write commands. What would be the most efficient implementation? Running each port in its own thread? Perhaps dedicate a core to running all of the serial port threads? How would I share the logs read into each serial port with the main thread running the computation/testing?
@awwwwhhhyeahhhh
@awwwwhhhyeahhhh 5 жыл бұрын
I'm just getting into threading for my kivy app. The reason being is that I have an nslookup function bound to a kivy button and on the button press a progress spinner should appear while the nslookup is running. However when I press the button the app freezes (presumably because the function is an nslookup and doesn't actually interact with the GUI). So my thinking is that I run the function and the progress spinner animation on different threads so the spinner doesn't have to wait for the nslookup to complete. Am I thinking along the right lines here? Will threading help me to achieve this or should I be looking into something else?
@muizzy
@muizzy 5 жыл бұрын
"Multithreading" is a very big word when it comes to plain python. You won't be getting any significant performance gain from doing it. If you want to achieve actual multi-threading in python, the best way I know of is to use Konrad Hinsen's modified Python interpreter together with his Bulk Synchronous Parallel (BSP) module included in his scientific python package: bitbucket.org/khinsen/scientificpython The problem is that Python's GIL will protest against any form of parallelisation. I tried to build a package that could deliver a Python based BSP package, but was unable to get the GIL to play nice in any generalised case. Hence, the project is currently on the backburner.
@TechWithTim
@TechWithTim 5 жыл бұрын
Yes you’re correct, to create parallelism you need to use multiprocessing! Multi threading is great for networking applications however because when waiting for tasks to be completed then you can have other threads running in the background. I will be doing a multiprocessing tutorial after this one !
@muizzy
@muizzy 5 жыл бұрын
@@TechWithTim ... wait ... You know of a way to get around the GIL?? Do you have any links to resources?
@TechWithTim
@TechWithTim 5 жыл бұрын
@@muizzy It's not necessarily getting around GIL... It's using multiple GIL, you can create more than one process of your program and have them run in parallel on separate cores or CPU's. The issue here is its much more difficult to share information between processes because they have their own memory location. Just try looking up the processing module in python, not sure if it will fix your issue but have a look.
@muizzy
@muizzy 5 жыл бұрын
@@TechWithTim Dude, this actually ended up fixing all my problems. Two days of frantic coding later, I've got a working (and beautiful) proof of concept!
@Hamheadon
@Hamheadon 3 жыл бұрын
My main wonder is what happens if you set two threads to delay for the same intervals of time
@kitgary
@kitgary 4 жыл бұрын
Any thought about the gevent? Is it good?
@munivoltarc
@munivoltarc Жыл бұрын
where did you learn this, can u share the resource, if it is a pdf?
@aryanbhatia6992
@aryanbhatia6992 5 жыл бұрын
When are deep learning tutorials coming ??
@ashishsrivastava123
@ashishsrivastava123 4 жыл бұрын
Please make video on vscode..its very good.. but lot of issue we face while running e.g. extension do not load, update json files etc ( Python ML developer )
@maulikmadhavi
@maulikmadhavi 3 жыл бұрын
why different number of empty spaces? Can anyone explain? Thanks
@manishkumar-bh6cc
@manishkumar-bh6cc 5 жыл бұрын
Bro can you upload a tutorial in webscraping in python
@hammzahammza7914
@hammzahammza7914 5 жыл бұрын
thank you very mush
@chujuntang3517
@chujuntang3517 5 жыл бұрын
I think it's Python which cannot run two threads at the same time due to GIL.
@marconarca2706
@marconarca2706 4 жыл бұрын
you can use concurrent
@sainco3036
@sainco3036 5 жыл бұрын
thanks.
@FeedFall8
@FeedFall8 5 жыл бұрын
OMG PYGAMES WEBSITE IS DOWN WHATS HAPPENING?!?!?!?!?
Python Multithreading Tutorial #2 - How to Create New Threads
10:39
Tech With Tim
Рет қаралды 17 М.
Unlocking your CPU cores in Python (multiprocessing)
12:16
mCoding
Рет қаралды 313 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
threading vs multiprocessing in python
22:31
Dave's Space
Рет қаралды 601 М.
The Fastest Way to Loop in Python - An Unfortunate Truth
8:06
mCoding
Рет қаралды 1,4 МЛН
15 Python Libraries You Should Know About
14:54
ArjanCodes
Рет қаралды 410 М.
#64 Python Tutorial for Beginners | MultiThreading
14:45
Telusko
Рет қаралды 451 М.
Transformers (how LLMs work) explained visually | DL5
27:14
3Blue1Brown
Рет қаралды 4,2 МЛН
Как устроен PYTHON
37:44
про АйТи | IT Pro
Рет қаралды 30 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН