Object instantiation and garbage collection

Van Gale cgale1 at _remove_home.com
Mon May 14 05:55:32 EDT 2001


I'm a little confused with some code I see in asyncore servers, where an
object is instantiated without a name to reference it, e.g. in Fredrik's
sample asyncore time server:

class TimeChannel(asyncore.dispatcher):
   ...

class TimeServer(asyncore.dispatcher):
    ...
    def handle_accept(self):
        channel, addr = self.accept()
        TimeChannel(channel)

Doesn't this run a risk of creating an object with a reference count of 0
which can then be garbage collected?

Thanks :)
Van






More information about the Python-list mailing list