Python's low level _thread module, allocate, acquire and release locks, mutually exclusive objects

preview_player
Показать описание
As you've requested, this is the first part of a five part mini-series on threads. We're going to go from zero assumed knowledge to being comfortable with threading and concurrency.

What are you waiting for?!
Рекомендации по теме
Комментарии
Автор

If you've found this useful in anyway, I'd really appreciate sharing it where you can so that more people can enjoy this resource! Watch out for a personal video I'm making on my own journey and how I changed career in my 30s from boring monotony to an exciting software engineering role. If ever you needed motivation or wanted my own specific advice on how to become a self-taught developer, then you make sure you don't miss it. Will be available next week!

LivePython
Автор

Dude I swear this is the only legit video I've found on _thread. Thank you. You might not have a lot of views, but you sure deserve them.

Cyber
Автор

1. I can see counter ids aare out of order but within a counter, why in both examples, the counting from a counter isn't interweaved with the counting from another counter?
2. What happens after mutex.release? It seems the for loop inside counter has to go next iteration and immediately acquire?
3. When are the opportunities for the counter from another thread to fight for runtime? Is it only when 1 counter has completed all its loop iterations?

Han-veuh
Автор

Thank you very much for your tutorials!

Murciallog
Автор

It bothered me to no end that it did not start real threading in the example: It was just working through each loop instance and then the next. No concurrency, nothing. I had to try to make it work myself and found out that the loop inside the function needs to do just one thing (even a simple print statement) besides using the lock to open the possibility for other threads to take the lock - and then you see threading at work and not just two nested loops. This would have been hugely helpful in the tutorial.

riessm
Автор

why label the variable mutex instead of lock? Is that the standard variable name?

AyazAmlani
Автор

Please use relevant real world scenario such as multiple users editing a file at the same time. Threading doesn't stick with the learner without a strong example to go with it.

zafraan