Python Query: Related to locking a resource in a multithreaded environment

tarun tarundevnani at
Tue Aug 19 08:25:18 CEST 2008

I think I need something called global interpreter lock which is accessible
to all the threads. But I am not sure how to implement this.

On Tue, Aug 19, 2008 at 11:28 AM, tarun <tarundevnani at> wrote:

>  Hello All,
> I've a configuration.ini file. This particular can be accessed by several
> threads of my application. Each thread can read/write configuration
> parameters from/to the configuration.ini file. I am using threading (Rlock)
> to lock the resource (configuration.ini file) while accessing it from any
> thread. I use the file available at
> for read/write.
> I did the following in one of my files:
> import threading
> class Synchronization:
>   def __init__(self):
>     self.mutex = threading.RLock()
> Now this I can create instances of the class Synchronization and use
> acquire/release to work on the shared resource. But every thread would need
> to import this class and hence each thread would create a separate instance
> of the class. This means several lock variables. But I think we need a
> global lock flag that is accessible across all the threads.
> How do i do this?
> Please let me know ASAP.
> Thanks In Advance,
> Tarun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list