On 21 Nov 2003 at 9:45, Brian Kelley wrote:I always get this particular terminology jumbled when it comes to python. There are two things going on, reference counting and garbage collection. Just to see if I have this straight:
globals.storage = None
I should point out that using this method to explicitely close the
storage is really exploiting python's garbage collector. While it works
in Python 2.3 and below it may not work in python 2.4 and above. That's
what I meant by a "cheap" solution. However, given the lack of
storage.close() there are few alternatives.
No, that's not gc, that's just ref counting (but maybe that's what you meant). -- Gordon
When a storage goes out of scope the current version of C Python finalizes the storage object relatively quickly. This is essentially calling the object's __del__ function. It is related to garbage collection in that when an object's reference count goes to zero, it can be finalized and also it can be garbage collected.
The point is that python doesn't document when to finalize or garbage collect and one technically shouldn't make assumptions about when this is going to happen, just that it will. I've been raked over the coals on this particular subject :) The following pythonic idiom doesn't work on storage objects:
storage = metakit.storage(...) try: # do some work on the storage finally: # ensure that the storage is closed storage.close()
So one has to trust the implementation of python to handle the details. For all intents and purposes CPython 2.3 will close down the storage for you 'very soon' after the storage goes out of scope (or the refcount goes to 0). You mileage may very if you are using jython for instance.
_______________________________________________
metakit mailing list - [EMAIL PROTECTED]
http://www.equi4.com/mailman/listinfo/metakit
_______________________________________________ metakit mailing list - [EMAIL PROTECTED] http://www.equi4.com/mailman/listinfo/metakit
