Exemple #1
0
def test2():
    re = background(function2)
    now = time.time()
    try:
        assert re.wait() == True
    except Exception as e:
        print e
Exemple #2
0
 def prefetch(fid):
     loadnext = [ 
             sharedmem.background(
                 lambda fidnext: prefetcher(fidnext),
                 fidnext)
             for fidnext in range(fid, fid + chunksize) if fidnext < Nfile ]
     return loadnext
Exemple #3
0
 def prefetch(fid):
     loadnext = [
         sharedmem.background(lambda fidnext: prefetcher(fidnext), fidnext)
         for fidnext in range(fid, fid + chunksize)
         if fidnext < Nfile
     ]
     return loadnext
def test_background():
    def function1():
        time.sleep(2)
        return True

    re = background(function1)
    now = time.time()
    assert re.wait() == True
    assert int(time.time() - now + 0.5) == 2
Exemple #5
0
def test_background():
    def function1():
        time.sleep(2)
        return True

    re = background(function1)
    now = time.time()
    assert re.wait() == True
    assert int(time.time() - now + 0.5) == 2
def test_background_raise():
    def function2():
        raise Exception('test exception')
        time.sleep(2)
    re = background(function2)
    now = time.time()
    try:
        assert re.wait() == True
    except Exception as e:
        return 

    raise AssertionError("Shall not reach here")
Exemple #7
0
def test_background_raise():
    def function2():
        raise Exception('test exception')
        time.sleep(2)

    re = background(function2)
    now = time.time()
    try:
        assert re.wait() == True
    except Exception as e:
        return

    raise AssertionError("Shall not reach here")
Exemple #8
0
def test1():
    re = background(function1)
    now = time.time()
    assert re.wait() == True
    assert int(time.time() - now + 0.5) == 3
    print 'test1'