Advertisement
rfmonk

weakref_cycle.py

Jan 15th, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import gc
  5. from pprint import pprint
  6. import weakref
  7.  
  8. from weakref_graph import Graph, demo, collect_and_show_garbage
  9.  
  10. gc.set_debug(gc.DEBUG_LEAK)
  11.  
  12. print 'Setting up the cycle'
  13. print
  14. demo(Graph)
  15.  
  16. print
  17. print 'Breaking the cycle and cleaning up the garbage'
  18. print
  19. gc.garbage[0].set_next(None)
  20. while gc.garbage:
  21.     del gc.garbage[0]
  22. print
  23. collect_and_show_garbage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement