示例#1
0
def waitForResults(graph, values, timeout=60.0):
    """wait for 'x' to have 'result' not be zero. return the maximum number
    of CPUs ever observed to be allocated to 'x'"""
    t0 = time.time()

    def notLoadedCount():
        notLoadedCount = 0

        for x in values:
            if x.valueIVC is None:
                notLoadedCount += 1

        return notLoadedCount

    with IncreasedRequestCount(values):
        maxCPUs = None
        while notLoadedCount() > 0 and time.time() - t0 < timeout:
            time.sleep(.01)
            BackgroundUpdateQueue.pullOne(timeout=.10)
            graph.flush()

            for x in values:
                if x.totalWorkerCount is not None:
                    if maxCPUs is None:
                        maxCPUs = x.totalWorkerCount
                    else:
                        maxCPUs = max(maxCPUs, x.totalWorkerCount)

        assert notLoadedCount(
        ) == 0, "Timed out: %s of %s didn't finish:\n\t%s\n" % (
            notLoadedCount(), len(values), "\n\t".join(
                [str(x) for x in values if x.valueIVC is None]))

        return maxCPUs
示例#2
0
    def waitUntilTrue(self, predicate, timeout=10.0):
        t0 = time.time()
        interval = 0.001
        while not predicate():
            time.sleep(interval)

            BackgroundUpdateQueue.pullOne(timeout=interval)
            self.graph.flush()

            if time.time() - t0 > timeout:
                self.assertFalse(True, "timed out")
                return

            interval = min(interval * 2, 0.1)
示例#3
0
    def waitUntilTrue(self, predicate, timeout = 10.0):
        t0 = time.time()
        interval = 0.001
        while not predicate():
            time.sleep(interval)

            BackgroundUpdateQueue.pullOne(timeout = interval)
            self.graph.flush()

            if time.time() - t0 > timeout:
                self.assertFalse(True, "timed out")
                return

            interval = min(interval * 2, 0.1)
示例#4
0
def waitCacheItemsAreLoaded(graph, cacheItems, timeout = 60.0):
    with IncreasedRequestCount(cacheItems):
        def allAreLoaded():
            for c in cacheItems:
                if not c.isLoaded:
                    return False

            return True

        t0 = time.time()

        while not allAreLoaded() and time.time() - t0 < timeout:
            BackgroundUpdateQueue.pullOne(timeout = 1.0)
            graph.flush()

        assert allAreLoaded(), "Timed out"
示例#5
0
def waitCacheItemsAreLoaded(graph, cacheItems, timeout=60.0):
    with IncreasedRequestCount(cacheItems):

        def allAreLoaded():
            for c in cacheItems:
                if not c.isLoaded:
                    return False

            return True

        t0 = time.time()

        while not allAreLoaded() and time.time() - t0 < timeout:
            BackgroundUpdateQueue.pullOne(timeout=1.0)
            graph.flush()

        assert allAreLoaded(), "Timed out"
示例#6
0
def waitForResults(graph, values, timeout = 60.0):
    """wait for 'x' to have 'result' not be zero. return the maximum number
    of CPUs ever observed to be allocated to 'x'"""
    t0 = time.time()

    def notLoadedCount():
        notLoadedCount = 0

        for x in values:
            if x.valueIVC is None:
                notLoadedCount += 1

        return notLoadedCount

    with IncreasedRequestCount(values):
        maxCPUs = None
        while notLoadedCount() > 0 and time.time() - t0 < timeout:
            time.sleep(.01)
            BackgroundUpdateQueue.pullOne(timeout = .10)
            graph.flush()

            for x in values:
                if x.totalWorkerCount is not None:
                    if maxCPUs is None:
                        maxCPUs = x.totalWorkerCount
                    else:
                        maxCPUs = max(maxCPUs,x.totalWorkerCount)

        assert notLoadedCount() == 0, "Timed out: %s of %s didn't finish:\n\t%s\n" % (
            notLoadedCount(),
            len(values),
            "\n\t".join(
                [str(x) for x in values if x.valueIVC is None]
                )
            )

        return maxCPUs
示例#7
0
def waitCacheItemIsLoaded(graph, cacheItem):
    with IncreasedRequestCount(cacheItem):
        while not cacheItem.isLoaded:
            BackgroundUpdateQueue.pullOne()
            graph.flush()
示例#8
0
def waitCacheItemIsLoaded(graph, cacheItem):
    with IncreasedRequestCount(cacheItem):
        while not cacheItem.isLoaded:
            BackgroundUpdateQueue.pullOne()
            graph.flush()