예제 #1
0
def t1():
    print 'expect [1024] * 10...'
    fd = os.open ('/kernel', os.O_RDONLY)
    # 10 1KB read requests
    requests = [
        (aio_read, (fd, 1024, int64(i * 102400)))
        for i in range (10)
        ]
    results = coro.in_parallel (requests)
    print [len(x) for x in results]
예제 #2
0
def t1():
    print 'expect [1024] * 10...'
    fd = os.open('/kernel', os.O_RDONLY)
    # 10 1KB read requests
    requests = [(aio_read, (fd, 1024, int64(i * 102400))) for i in range(10)]
    results = coro.in_parallel(requests)
    print[len(x) for x in results]
    print 'expect one OSError at the end...'
    fd = os.open('/kernel', os.O_RDONLY)
    # 10 1KB read requests
    requests = [(aio_read, (fd, 1024, int64(i * 102400))) for i in range(10)]
    requests.append((aio_read, (-1, 1024, 1024L)))
    try:
        coro.in_parallel(requests)
    except coro.InParallelError, e:
        for i in xrange(len(e.partial_results)):
            status, result = e.partial_results[i]
            if status is coro.SUCCESS:
                print 'job %2d:' % i, status, len(result)
            else:
                print 'job %2d:' % i, status, result
예제 #3
0
파일: tclient.py 프로젝트: amitdev/shrapnel
def t1():
    c = http_client ('127.0.0.1', 80)
    rl = coro.in_parallel ([(c.GET, ('/postgresql/html/',))] * 10)
    for x in rl:
        W ('%s\n' % (x.response,))
    return rl
예제 #4
0
        for i in range (10)
        ]
    results = coro.in_parallel (requests)
    print [len(x) for x in results]
    print 'expect one OSError at the end...'
    fd = os.open ('/kernel', os.O_RDONLY)
    # 10 1KB read requests
    requests = [
        (aio_read, (fd, 1024, int64(i * 102400)))
        for i in range (10)
        ]
    requests.append (
        (aio_read, (-1, 1024, 1024L))
        )
    try:
        coro.in_parallel (requests)
    except coro.InParallelError, e:
        for i in xrange (len(e.partial_results)):
            status, result = e.partial_results[i]
            if status is coro.SUCCESS:
                print 'job %2d:' % i, status, len(result)
            else:
                print 'job %2d:' % i, status, result
    else:
        raise SystemError, "expected an exception"

if __name__ == '__main__':
    import backdoor
    coro.spawn (backdoor.serve)
    coro.spawn (t1)
    coro.event_loop (30.0)
예제 #5
0
def t1():
    c = http_client('127.0.0.1', 80)
    rl = coro.in_parallel([(c.GET, ('/postgresql/html/', ))] * 10)
    for x in rl:
        W('%s\n' % (x.response, ))
    return rl