Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,155,160 members, 7,825,634 topics. Date: Sunday, 12 May 2024 at 07:25 PM

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

Nairaland Forum / Science/Technology / Programming / Help On How To Use Threading.lock() In Python (802 Views)

Tutorial: Object Oriented Programming Paradigm For Beginners in Python / Who Wants To Learn Programming In Python Easily Without Stress? READ THIS / What No One Tells You About Coding In Python: Eye-opening! (2) (3) (4)

(1) (Reply) (Go Down)

Help On How To Use Threading.lock() In Python by gbolly1151(m): 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.

2 Likes

Re: Help On How To Use Threading.lock() In Python by gbolly1151(m): 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.

1 Like

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)

Javascript Pricing Table Toggle Between 3 States. / Salesforce Online Training And Certification / Darkweb: See How Porn Links Dude Spy On Your Phone And Laptops With Links

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.