@threadsafe_function
    def connect(self):
        log.debug('connections: %s, in_use: %s' % (self.connections, self.in_use))
        for id, instance in self.connections.items():
            if id in self.in_use:
                log.debug('id %d in use' % id)
                continue
            return self.got_conn(instance, id)

        # no free ones, create a new one
        log.debug('creating a new connection')
        for id in range(self.max_connections):
            log.debug('checking id: %d' % id)
            if id in self.connections:
                continue
            else:
                log.debug('new connection id: %d' % id)
                mpdc = self.factory(self.g)
                d = mpdc.connect()
                return self.got_conn(d, id)

        # max connections, check overflow

        for id, instance in self.overflow_connections.items():
            if id in self.overflow_in_use:
                log.debug(id % 'overflow id %d in use')
                continue
            return self.got_conn(instance, id, overflow=True)

        for id in range(self.max_overflow):
            if id in self.overflow_connections:
                continue
            else:
                log.debug('new overflow connection id: %d' % id)
                mpdc = self.factory(self.g)
                d = mpdc.connect()
                return self.got_conn(d, id, overflow=True)

        raise MaxConnections
dataset/ETHPy150Open ralfonso/theory/theory/model/mpdpool.py/MPDPool.connect/swapped operands of `%`