₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,324,997 members, 8,419,863 topics. Date: Thursday, 04 June 2026 at 04:07 AM

Toggle theme

Help On How To Use Threading.lock() In Python - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp On How To Use Threading.lock() In Python (955 Views)

1 Reply (Go Down)

Help On How To Use Threading.lock() In Python by gbolly1151(op): 11:21am On Nov 15, 2019
I was trying to get the concept of threading.Lock() on python but can't really figure out how it work with the two method acquire() and release()

Can some explain in details how to use it effectively and when to use?
Re: Help On How To Use Threading.lock() In Python by stanliwise(m): 1:10pm On Nov 16, 2019
gbolly1151:
I was trying to get the concept of threading.Lock() on python but can't really figure out how it work with the two method acquire() and release()

Can some explain in details how to use it effectively and when to use?
what where you tryna do with it?
Re: Help On How To Use Threading.lock() In Python by stanliwise(m): 1:16pm On Nov 16, 2019
gbolly1151:
I was trying to get the concept of threading.Lock() on python but can't really figure out how it work with the two method acquire() and release()

Can some explain in details how to use it effectively and when to use?
When creating app that run multiple processes(threads). There are chances that two or more threads may access one variable, which may lead to data leakage, to avoid this, you have to synchronize access to such variable.
Meaning you have to lock it and give key to a thread, to maintain linear access.
Re: Help On How To Use Threading.lock() In Python by gbolly1151(op): 7:30am On Nov 17, 2019
stanliwise:
When creating app that run multiple processes(threads). There are chances that two or more threads may access one variable, which may lead to data leakage, to avoid this, you have to synchronize access to such variable.
Meaning you have to lock it and give key to a thread, to maintain linear access.
Thanks so much... Got it,but is process the same as thread?
Re: Help On How To Use Threading.lock() In Python by stanliwise(m): 8:01am On Nov 17, 2019
gbolly1151:
Thanks so much... Got it,but is process the same as thread?
https://stackoverflow.com/questions/200469/what-is-the-difference-between-a-process-and-a-thread

I think this should explain it. Thread uses the same shared memory within a process. While process uses different memory(global) space.
But they are basically the same. and multiple process could need to access one resources and synchronization will need to make proper use of resources. Same for threads try to access a global memory space in a process. The idea is the same.
Re: Help On How To Use Threading.lock() In Python by OlamigokePhilip: 9:15am On Nov 18, 2019
I will suggest you also go through this post on StackOverF as well; https://stackoverflow.com/questions/3044580/multiprocessing-vs-threading-python

If you would like to document your findings on this topic.. You may give https://minify.tech a try. It allows you document your errors, solutions and findings.. easy access later on and shareable with a larger community if you want to.

1 Reply

I Need Help On How To Avoid BurnoutTutorial: Object Oriented Programming Paradigm For Beginners in PythonWho Wants To Learn Programming In Python Easily Without Stress? READ THIS234

What Stopping You From Building Your Own Company?20 Things You Must Never Do If You Want To Be A Successful DeveloperAny Visual Foxpro User Here