Re: Instance method decorator garbage collection problem

2010-06-23 Thread Thomas Jollans
On 06/23/2010 02:56 PM, John Reid wrote: > > > Thomas Jollans wrote: >>> The InstanceCounted.count is 1 at the end. If I omit the call to >>> "self.method = print_exception_decorator(self.method)" then the instance >>> count goes down to 0 as desired. I thought that the decorator might be >>> hol

Re: Instance method decorator garbage collection problem

2010-06-23 Thread John Reid
Thomas Jollans wrote: The InstanceCounted.count is 1 at the end. If I omit the call to "self.method = print_exception_decorator(self.method)" then the instance count goes down to 0 as desired. I thought that the decorator might be holding a reference to the instance through the bound method, so

Re: Instance method decorator garbage collection problem

2010-06-23 Thread Christian Heimes
> The InstanceCounted.count is 1 at the end. If I omit the call to > "self.method = print_exception_decorator(self.method)" then the instance > count goes down to 0 as desired. I thought that the decorator might be > holding a reference to the instance through the bound method, so I added > t

Re: Instance method decorator garbage collection problem

2010-06-23 Thread Peter Otten
John Reid wrote: > Hi, > > I've written a decorator that prints exceptions and I'm having some > trouble with garbage collection. > > My decorator is: > > import sys > def print_exception_decorator(fn): > def decorator(self, *args, **kwds): > try: > return fn(*args, *

Re: Instance method decorator garbage collection problem

2010-06-23 Thread Thomas Jollans
On 06/23/2010 01:40 PM, John Reid wrote: > Hi, > > I've written a decorator that prints exceptions and I'm having some > trouble with garbage collection. > > My decorator is: > > import sys > def print_exception_decorator(fn): > def decorator(self, *args, **kwds): > try: >

Instance method decorator garbage collection problem

2010-06-23 Thread John Reid
Hi, I've written a decorator that prints exceptions and I'm having some trouble with garbage collection. My decorator is: import sys def print_exception_decorator(fn): def decorator(self, *args, **kwds): try: return fn(*args, **kwds) except: print '