Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64506
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-01-22 08:03 -0800 |
| References | <0d1fc1a7-c585-45ba-8c1a-0cc468712a48@googlegroups.com> <mailman.5829.1390360114.18130.python-list@python.org> <58c541ab-c6e1-45a8-b03a-8597ed7ecb48@googlegroups.com> <mailman.5832.1390381001.18130.python-list@python.org> |
| Message-ID | <9729ddaa-5976-4e53-8584-6198b47b6789@googlegroups.com> (permalink) |
| Subject | Re: Self healthcheck |
| From | Asaf Las <roegltd@gmail.com> |
On Wednesday, January 22, 2014 10:56:30 AM UTC+2, Frank Millman wrote:
>
> class MainObject:
> def __init__(self, identifier):
> self._del = delwatcher('MainObject', identifier)
> class delwatcher:
> def __init__(self, obj_type, identifier):
> self.obj_type = obj_type
> self.identifier = identifier
> log('{}: id={} created'.format(self.obj_type, self.identifier))
> def __del__(self):
> log('{}: id={} deleted'.format(self.obj_type, self.identifier))
> If you do find that an object is not being deleted, it is then
> trial-and-error to find the problem and fix it. It is probably a circular
> reference
>
> Frank Millman
Thanks Frank. Good approach!
One question - You could do:
class MainObject:
def __init__(self, identifier):
self._del = delwatcher(self)
then later
class delwatcher:
def __init__(self, tobject):
self.obj_type = type(tobject)
self.identifier = id(tobject)
...
when creating delwatcher. Was there special reason to not to use them?
is this because of memory is reused when objects are deleted
and created again so same reference could be for objects created
in different time slots?
Thanks
Asaf
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Self healthcheck Asaf Las <roegltd@gmail.com> - 2014-01-21 18:51 -0800
Re: Self healthcheck Chris Angelico <rosuav@gmail.com> - 2014-01-22 14:08 +1100
Re: Self healthcheck Asaf Las <roegltd@gmail.com> - 2014-01-22 00:18 -0800
Re: Self healthcheck Nicholas Cole <nicholas.cole@gmail.com> - 2014-01-22 08:43 +0000
Re: Self healthcheck Asaf Las <roegltd@gmail.com> - 2014-01-22 07:51 -0800
Re: Self healthcheck "Frank Millman" <frank@chagford.com> - 2014-01-22 10:56 +0200
Re: Self healthcheck Asaf Las <roegltd@gmail.com> - 2014-01-22 08:03 -0800
Re: Self healthcheck Dave Angel <davea@davea.name> - 2014-01-22 13:40 -0500
Re: Self healthcheck "Frank Millman" <frank@chagford.com> - 2014-01-23 07:36 +0200
csiph-web