def close(self, callback=None):

        if self.status not in (status.OPENING, status.OPENED):
            raise AmqpStatusError('connection is not open')

        self._close_callback = callback
        self.status = status.CLOSING

        for ch in self.channels.values():
            if ch is not self and ch.status in (status.OPENING, status.OPENED):
                ch.close(self.close)

        m = Close(reply_code=0, reply_text='', class_id=0, method_id=0)
        self.send_method(m, self._close_callback)
cleanly closes the connection to the server.
dataset/ETHPy150Open paolo-losi/stormed-amqp/stormed/connection.py/Connection.close