Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / usr / lib / python2.7 / dist-packages / twisted / python / | server ip : 104.21.89.46 your ip : 172.70.127.169 H O M E |
Filename | /usr/lib/python2.7/dist-packages/twisted/python/finalize.py |
Size | 767 |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 27-Apr-2025 09:56 |
Last modified | 07-May-2003 21:56 |
Last accessed | 06-Jul-2025 19:30 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
"""
A module for externalized finalizers.
"""
import weakref
garbageKey = 0
def callbackFactory(num, fins):
def _cb(w):
del refs[num]
for fx in fins:
fx()
return _cb
refs = {}
def register(inst):
global garbageKey
garbageKey += 1
r = weakref.ref(inst, callbackFactory(garbageKey, inst.__finalizers__()))
refs[garbageKey] = r
if __name__ == '__main__':
def fin():
print 'I am _so_ dead.'
class Finalizeable:
"""
An un-sucky __del__
"""
def __finalizers__(self):
"""
I'm going away.
"""
return [fin]
f = Finalizeable()
f.f2 = f
register(f)
del f
import gc
gc.collect()
print 'deled'