Ńň
đgcJc           @   s5   d  Z  d d k 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 C{__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 L{register}, and when an object is garbage
    collected, each registered resource is closed by having its C{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   h  |  _  d  S(   N(   t   _table(   t   self(    (    sP   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\resource.pyt   __init__+   s    c            s5      f d   } t  i | |   i t    <d S(   sĎ  
        Register a resource to be closed with an object is collected.
        
        When the given C{obj} is garbage-collected by the python interpreter,
        the C{resource} will be closed by having its C{close()} method called.
        Any exceptions are ignored.
        
        @param obj: the object to track
        @type obj: object
        @param resource: the resource to close when the object is collected
        @type resource: object
        c            s,   y   i    Wn n X i t    =d  S(   N(   t   closeR   t   id(   t   ref(   t   resourceR   (    sP   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\resource.pyt   callback;   s
    N(   t   weakrefR   R   R   (   R   t   objR   R   (    (   R   R   sP   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\resource.pyt   register.   s    	(   t   __name__t
   __module__t   __doc__R   R   (    (    (    sP   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\resource.pyR       s   	(   R   R	   t   objectR    (    (    (    sP   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\resource.pyt   <module>   s   .