Re: AW: DorothyLocker and performance

Thomas Klaeger <[email protected]> Thu, 30 Sep 2004 17:00:36 +0200
Newsgroups gmane.comp.pythin.pyds.devel
Message-ID <[email protected]>
Hello Garth,

Garth T Kidd schrieb:
> Did the unit tests show anything before you applied your fix? If I need
> another regression test, I'd like to add it. If not, it looks like the code
> is in pretty good shape. All I need to do now is figure out why ignoring
> self._acquire.func_code wasn't working in situ... 

This was the only indication:

>>_acquire: 
>>Exception exceptions.AssertionError: 
>>('/opt/pyds/lib/python2.2/site-packages/PyDS/Tool.py', 1393, 
>>'_acquire', 'return self.lock.acquire(blocking)') 
>>('/opt/pyds/lib/python2.2/site-packages/PyDS/DorothyLocker.py', 342, 
>>'acquire', 'assert result # ... but you can never be too careful.')

the assert failed! Digging into the python documentation I found that 
thread.lock.acquire() returns nothing if called without arguments. The 
remaining error messages from below

>>-----------------------
>>ReleaseOfUnAcquiredLock
>>-----------------------
>>An attempt to release an un-acquired lock. Probably caused by failure 
>>to acquire.
>>Detection context:
>>  File "/opt/pyds/lib/python2.2/site-packages/PyDS/EventsTool.py", 
>>line 93, in _log
>>  File "/opt/pyds/lib/python2.2/site-packages/PyDS/EventsTool.py", 
>>line 99, in _logVerbose

... some stack trace cut off ...

>>line 290, in __sanity_check
>>    raise ReleaseOfUnAcquiredLock, (None, my_context)
>>ReleaseOfUnAcquiredLock: (None, <PyDS.DorothyLocker.CallingContext 
>>object at
>>0x8927614>, 'An attempt to release an un-acquired lock. Probably 
>>0x8927614>caused by
>>failure to acquire.')
>>

stems from the fact that the code is written as

try:
     self.lock.acquire()
     ...
finally:
     self.lock.release()

which leads to the release of an unacquired lock if the locking itself 
fails.

Regards,
Thomas