If you acquire lock using with statement. It will make sure lock will always be released.
@ΑρηςΕμπαντα Жыл бұрын
I didnt get it... First we had synchronous code. Then we deployed threads to do things concurrently (awesome for I/O bound tasks), and then with locking we made the code synchronous again? For what you want to perform, either multiprocessing can help you, or to switch to other programming language like C# or Java that actually runs threads in parallel.... Why doesn't nobody else in the comment section address that stuff?
@tomekk.1889 Жыл бұрын
I don't understand what you mean. Locking is used so there's no race conditions between the threads. His example wasn't good though. He should have explained it using producers and consumers
@monishsudhagar Жыл бұрын
Yeah, just bad use case. When you work with produces and consumers or any multithreaded application with a shared state, then locking starts to make sense
@hams646811 ай бұрын
Locking is useful if for example - you have to make an API request to pull some data & then cache it. You simply lock so that a thread can go and pull data from an api & cache it, then all other threads can use that cache.
@chriskeo1982 жыл бұрын
best video on threading!
@iniyan192 жыл бұрын
thanks !!! i was searching for this!!!
@scottlee382 жыл бұрын
I ran into this same issue with thread locks. Wish there was a way to get around it so that I could keep threads for certain loops "always running".
@ilanbar19702 жыл бұрын
Well explained. Thanks!
@BrianStDenis-pj1tq2 жыл бұрын
You pretty much said Python doesn't have multi-threading, presumably due to the impact of the GIL. I'd say that Python does have multi-threading, and the GIL. Which means that for CPU bound threads, its very similar to having a single CPU. But, for I/O threads, it works great.
@ΑρηςΕμπαντα Жыл бұрын
You just can use multiprocessing if you have a 4 core CPU to do 4 CPU bound tasks in paralel... But true for I/O tasks python threads are great
@DG-mo1nw2 жыл бұрын
Thanks for the videos been learning a lot. Is there any way you could do a video using tradingview webhooks for indicators for a trading bot using python?
@good-oe2cz9 ай бұрын
it was a bit rough explanations. with better example and concept of context change, it would be a better explanation. thank you for your video.