469,627 Members | 1,069 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,627 developers. It's quick & easy.

Re: Python Query: Related to locking a resource in a multithreadedenvironment

On Mon, Aug 18, 2008 at 10:58 PM, tarun <ta**********@gmail.comwrote:
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
http://www.voidspace.org.uk/python/configobj.html 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
--
http://mail.python.org/mailman/listinfo/python-list
Does making it a class level instead of instance level variable not work?

--
Stand Fast,
tjg. [Timothy Grant]
Aug 19 '08 #1
0 940

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Andreas Huesgen | last post: by
9 posts views Thread by cgwalters | last post: by
reply views Thread by =?UTF-8?B?TmlscyBPbGl2ZXIgS3LDtmdlcg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.