__del__ problem - more details provided. still stumped though.
gmcm at hypernet.com
Wed Apr 19 10:55:05 EDT 2000
Warren Postma wrote:
> class DBPtr :
> def __init__(self,this):
> self.this = this
> self.thisown = 0
> def __del__(self):
> if self.thisown == 1 :
> dbc.delete_DB(self.this) # appears some exceptions being raised
> # rest of class DBPtr snipped
Patch that to
def __del__(self, dbc=dbc):
The problem is that the Py_Finalize logic has a real hard time
knowing in what order to zap things. By the time this __del__
runs, the dbc module has already been zapped. Squirrelling
away a reference in the method definition will ensure it's
existence. In general, a __del__ method (or anything called
from a __del__ method) cannot rely on any references outside
the object unless it uses this trick.
> That still leaves the two messages regarding unknown attribute named "time".
> the only reference to time in my modules is calls to time.time() in a
> function that could be called in the destructor of the table objects, while
> updating the table headers one last time before closing the file.
More information about the Python-list