Python Multithreading Tutorial #1 - What is a Thread?
HTML-код
- Опубликовано: 7 сен 2024
- This python multithreading tutorial talks about what a thread is and how it compares to a process. Multithreading is a commonly used strategy to improve the efficiency of code. When multiple threads are running if the current thread delays or is waiting for something then the next thread will start executing.
Source-Code: Coming soon...
Playlist: • Python Multithreading ...
◾◾◾◾◾
💻 Enroll in The Fundamentals of Programming w/ Python
tech-with-tim.....
📸 Instagram: / tech_with_tim
🌎 Website techwithtim.net
📱 Twitter: / techwithtimm
⭐ Discord: / discord
📝 LinkedIn: / tim-rusci. .
📂 GitHub: github.com/tec...
🔊 Podcast: anchor.fm/tech...
💵 One-Time Donations: www.paypal.com....
💰 Patreon: / techwithtim
◾◾◾◾◾◾
⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡
Tags:
- Tech With Tim
- Multithreading in python
- Python multithreading tutorial
- Python Tutorials
PLEASE DO MORE PYTHON PROBLEMS AND SOLUTIONS!!
Like one a week?
Possibly!
Pro trick: you can watch series at flixzone. Me and my gf have been using them for watching lots of of movies lately.
this video helped me reduce lag in my applications that have over 250,000 objects
nice video man, i was unable to understand at beginning when i looked at the code, but then i understood evrything after your illustrations.
Awesome! Glad to hear that :)
also Great video As usual Tim :)
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.
Awesome tutorial dude! You're really talented :))
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?
good question, yes you would have to wait. There is ways around this however...
@@TechWithTim thanks Tim
I think thread priority is not controllable in Python due to unawareness of GIL to switch thread.
Perfect explanation .. keep it up 👻👍👍👌
"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.
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 !
@@TechWithTim ... wait ...
You know of a way to get around the GIL??
Do you have any links to resources?
@@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.
@@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!
thanks.
My main wonder is what happens if you set two threads to delay for the same intervals of time
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?
thank you very mush
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 )
When are deep learning tutorials coming ??
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?
why different number of empty spaces? Can anyone explain? Thanks
Bro can you upload a tutorial in webscraping in python
Any thought about the gevent? Is it good?
where did you learn this, can u share the resource, if it is a pdf?
I think it's Python which cannot run two threads at the same time due to GIL.
you can use concurrent
OMG PYGAMES WEBSITE IS DOWN WHATS HAPPENING?!?!?!?!?