@defer.inlineCallbacks
    def terminate(self, header, connection_id, request_info=None):

        log.msg('', system=LOG_SYSTEM)
        log.msg((header.requester_nsa, connection_id) % 'Terminate request. NSA: %s. Connection ID: %s', system=LOG_SYSTEM)

        conn = yield self.getConnection(connection_id)

        if conn.lifecycle_state == state.TERMINATED:
            defer.returnValue(connection_id) # all good

        yield state.terminating(conn)

        defs = []
        sub_connections = yield self.getSubConnectionsByConnectionKey(conn.id)

        for sc in sub_connections:
            # we assume a provider is available
            provider = self.getProvider(sc.provider_nsa)
            header = nsa.NSIHeader(self.nsa_.urn(), sc.provider_nsa, security_attributes=header.security_attributes)
            d = provider.terminate(header, sc.connection_id, request_info)
            d.addErrback(_logErrorResponse, connection_id, sc.provider_nsa, 'terminate')
            defs.append(d)

        results = yield defer.DeferredList(defs, consumeErrors=True)

        successes = [ r[0] for r in results ]
        if all(successes):
            log.msg('Connection %s: All sub connections(%i) acked terminated' % (conn.connection_id, len(defs)), system=LOG_SYSTEM)
            defer.returnValue(connection_id)
        else:
            # we are now in an inconsistent state...
            n_success = sum( [ 1 for s in successes if s ] )
            log.msg('Connection %s. Only %i of %i connections successfully terminated' % (conn.connection_id, n_success, len(defs)), system=LOG_SYSTEM)
            provider_urns = [ sc.provider_nsa for sc in sub_connections ]
            raise _createAggregateException(connection_id, 'terminate', results, provider_urns, error.ConnectionError)
dataset/ETHPy150Open NORDUnet/opennsa/opennsa/aggregator.py/Aggregator.terminate/swapped operands of `%`