

def close(self, callback=None):
    'cleanly closes the connection to the server.\n\n        all pending tasks are flushed before connection shutdown'
    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)

dataset/ETHPy150Open paolo-losi/stormed-amqp/stormed/connection.py Connection.close/original