File: weakreftest.py

package info (click to toggle)
egenix-mx-base 3.1.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 12,504 kB
  • ctags: 5,469
  • sloc: ansic: 21,355; python: 14,724; sh: 137; makefile: 102
file content (23 lines) | stat: -rw-r--r-- 518 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import sys
import mx.Proxy

class Object:
   def __init__(self, id):
      self.id = id
   def __del__(self):
      print self.id, 'deleted'
   def __repr__(self):
      return '<Object %s at %d (0x%x)>' % (self.id, id(self), id(self))

def  test():
   x = Object('first')
   x.y = Object('second')
   x.y.x = mx.Proxy.WeakProxy(x)

test()

# if I uncomment the following, everything works as expected, which suggests
# to me that either the WeakReferences dictionary is not getting GC'd
#y = x.y
#del x
#print y.x.id