code: def set_close_callback(self, cb):
          
          assert self._close_cb is None, (
              'A close_callback has already been set for this connection.'
          )
          self._close_cb = stack_context.wrap(cb)
          if self.closed:
              self._close_cb()
docs: Specify a function to be called when this connection is closed.
  
          :param cb:
              A callable that takes no arguments. This callable will be called
              when this connection is closed.