Current File : //usr/lib/python2.7/site-packages/paramiko/resource.pyc |
�
=OXc @ s5 d Z d d l Z d e f d � � YZ e � Z d S( s
Resource manager.
i����Nt ResourceManagerc B s e Z d Z d � Z d � Z RS( 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.)
c C s
i | _ d S( N( t _table( t self( ( s5 /usr/lib/python2.7/site-packages/paramiko/resource.pyt __init__+ s c s5 � � f d � } t j | | � � j t � � <d S( 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
c s, y � j � Wn n X� j t � � =d S( N( t closeR t id( t ref( t resourceR ( s5 /usr/lib/python2.7/site-packages/paramiko/resource.pyt callback: s
N( t weakrefR R R ( R t objR R ( ( R R s5 /usr/lib/python2.7/site-packages/paramiko/resource.pyt register. s ( t __name__t
__module__t __doc__R R ( ( ( s5 /usr/lib/python2.7/site-packages/paramiko/resource.pyR s ( R R t objectR ( ( ( s5 /usr/lib/python2.7/site-packages/paramiko/resource.pyt <module> s -