Message238680
| 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) |
|