IClosable

Interface that allows you to create a component with a method that closes it and frees used resources.

Description

The IClosable interface allows you to create a component with a method that closes it and frees used resources.

Instance methods

close

Closes a component and frees used resources.

close(context: Optional[IContext])

  • context: IContext - (optional) a context to trace execution through a call chain.

Examples

class MyConnector(IClosable):
    _client = None
    
    ... # The _client can be lazy created
    
    def close(self, context):
        if self._client is not None:
            self._client.close()
            self._client = None  

See also