Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/twisted_8_1/twisted/python/finalize.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1
2 """
3 A module for externalized finalizers.
4 """
5
6 import weakref
7
8 garbageKey = 0
9
10 def callbackFactory(num, fins):
11 def _cb(w):
12 del refs[num]
13 for fx in fins:
14 fx()
15 return _cb
16
17 refs = {}
18
19 def register(inst):
20 global garbageKey
21 garbageKey += 1
22 r = weakref.ref(inst, callbackFactory(garbageKey, inst.__finalizers__()))
23 refs[garbageKey] = r
24
25 if __name__ == '__main__':
26 def fin():
27 print 'I am _so_ dead.'
28
29 class Finalizeable:
30 """
31 An un-sucky __del__
32 """
33
34 def __finalizers__(self):
35 """
36 I'm going away.
37 """
38 return [fin]
39
40 f = Finalizeable()
41 f.f2 = f
42 register(f)
43 del f
44 import gc
45 gc.collect()
46 print 'deled'
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/python/filepath.py ('k') | third_party/twisted_8_1/twisted/python/formmethod.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698