<div dir="ltr"><div><font face="tahoma,sans-serif">Hello All,<br> <br>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 </font><a href="http://www.voidspace.org.uk/python/configobj.html"><font face="tahoma,sans-serif">http://www.voidspace.org.uk/python/configobj.html</font></a><font face="tahoma,sans-serif"> for read/write. (configobj.py)<br>
 </font></div>
<div><font face="tahoma,sans-serif">I've used RLock to lock the resource.</font></div>
<div><font face="tahoma,sans-serif"><br>I see this error while accessing variables of the configuration.ini file</font>  </div>
<div> </div>
<div><font face="courier new,monospace" color="#000099">Exception in thread Thread-3:<br>Traceback (most recent call last):<br>  File "C:\Python25\lib\threading.py", line 460, in __bootstrap<br>    self.run()<br>
  File "F:\abc.py", line 229, in run<br>    option1 = conf['OPT1']<br>  File "F:\configobj.py", line 551, in __getitem__<br>    val = dict.__getitem__(self, key)<br>KeyError: 'OPT1'</font></div>

<div><font face="Courier New" color="#000099"></font> </div>
<div><font face="courier new,monospace" color="#000099">Exception in thread Thread-1:<br>Traceback (most recent call last):<br>  File "C:\Python25\lib\threading.py", line 460, in __bootstrap<br>    self.run()<br>
  File "F:\def.py", line 130, in run<br>    option2 = self.conf['OPT2']<br>  File "F:\configobj.py", line 551, in __getitem__<br>    val = dict.__getitem__(self, key)<br>KeyError: 'OPT2'</font></div>

<div><font face="Courier New" color="#000099"></font> </div>
<div><font face="tahoma,sans-serif" color="#000000">Can any one help me with a code for locking a resource across threads.</font></div>
<div><font face="tahoma,sans-serif" color="#000000"></font> </div>
<div><font face="tahoma,sans-serif" color="#000000">One more observation. I tried the following code on Python Idle</font></div>
<div><font face="Courier New" color="#000099"></font> </div>
<div><font face="courier new,monospace" color="#000099">>>> import threading<br>>>> threading.RLock()<br><_RLock(None, 0)><br>>>> threading.Lock()<br><thread.lock object at 0x019350B0></font></div>

<div> </div>
<div><font face="tahoma,sans-serif">Why does threading.RLock() return None</font></div>
<div><br><font face="tahoma,sans-serif">Thanks In Advance,<br>Tarun</font></div></div>