Unexpected exception thrown in __del__

Charles Hixson charleshixsn at earthlink.net
Mon May 21 11:55:09 EDT 2012


On 05/21/2012 08:29 AM, Charles Hixson wrote:
> message excerpt:
> flush: sql =  insert or replace into persists (id, name, data, rdCnt, 
> rdTim, wrCnt, wrTim, deprecation) values (?, ?, ?, ?, ?, ?, ?, ?)
> Exception TypeError: "'NoneType' object is not callable" in <bound 
> method Shelve2.__del__ of <__main__.Shelve2 object at 0x7ff4c0513f90>> 
> ignored
>
> flush is being called from within __del__.  I've narrowed it down to:
>         print ("flush: sql = ", sql)
>         curTim    =    nowI()
>         print ("flush: curTim = ", curTim)
>
> nowI() is a function defined at the top of the file, and before the 
> class, thus:
> def    nowI():
>     t    =    int (time() * 100)
>     return    t
>
> All I can guess is that there's some reason that an external to the 
> class function shouldn't be called during a __del__.  Is this correct?
>
That seems to be the answer, as replacing the call to nowI() in flush() 
with:
curTim = int (time() * 100)
fixes the problem.

Rereading the documentation, I guess that this should have been 
expected, but if nowI() were a static method of the class, would that 
have avoided the problem?  A class method?


-- 
Charles Hixson




More information about the Python-list mailing list