�
=OXc@s5dZddlZdefd��YZe�ZdS(s
Resource manager.
i����NtResourceManagercBs eZdZd�Zd�ZRS(s�
A registry of objects and resources that should be closed when those
objects are deleted.
This is meant to be a safer alternative to Python's ``__del__`` method,
which can cause reference cycles to never be collected. Objects registered
with the ResourceManager can be collected but still free resources when
they die.
Resources are registered using `register`, and when an object is garbage
collected, each registered resource is closed by having its ``close()``
method called. Multiple resources may be registered per object, but a
resource will only be closed once, even if multiple objects register it.
(The last object to register it wins.)
cCs
i|_dS(N(t_table(tself((s5/usr/lib/python2.7/site-packages/paramiko/resource.pyt__init__+scs5��fd�}tj||��jt��<dS(s�
Register a resource to be closed with an object is collected.
When the given ``obj`` is garbage-collected by the Python interpreter,
the ``resource`` will be closed by having its ``close()`` method called.
Any exceptions are ignored.
:param object obj: the object to track
:param object resource:
the resource to close when the object is collected
cs,y�j�WnnX�jt��=dS(N(tcloseRtid(tref(tresourceR(s5/usr/lib/python2.7/site-packages/paramiko/resource.pytcallback:s
N(tweakrefRRR(RtobjRR((RRs5/usr/lib/python2.7/site-packages/paramiko/resource.pytregister.s (t__name__t
__module__t__doc__RR(((s5/usr/lib/python2.7/site-packages/paramiko/resource.pyRs (RR tobjectR(((s5/usr/lib/python2.7/site-packages/paramiko/resource.pyt<module>s- |