This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients Alexey Kazantsev, Vadim Markovtsev, amaury.forgeotdarc, pitrou
Date 2015-03-20.14:30:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1426861829.88.0.301291691525.issue23720@psf.upfronthosting.co.za>
In-reply-to
Content
Amaury is right. In your case you could keep track of the Vectors in the Device object and invalidate them when the Device is destroyed (using e.g. a WeakSet). Or Vector could delegate its destruction to Device, e.g.:


class Device(object):        
    destroyed = False

    def __del__(self):
        self.destroyed = True

    def _dealloc_vector(self, v):
        if not self.destroyed:
            ...


class Vector(object):        
    def __init__(self, device):
        self.device = device
        
    def __del__(self):
        self.device._dealloc_vector(self)
History
Date User Action Args
2015-03-20 14:30:29pitrousetrecipients: + pitrou, amaury.forgeotdarc, Vadim Markovtsev, Alexey Kazantsev
2015-03-20 14:30:29pitrousetmessageid: <1426861829.88.0.301291691525.issue23720@psf.upfronthosting.co.za>
2015-03-20 14:30:29pitroulinkissue23720 messages
2015-03-20 14:30:29pitroucreate