예제 #1
0
파일: test_state.py 프로젝트: denz/swarm
def generator():
    with atomic(*range(10)) << 'subgenerator':
        value = transport.value[0]
        yield value
        with atomic(value) << _:
            yield value + 10
            subgenerator(value)
예제 #2
0
파일: test_atomic.py 프로젝트: denz/swarm
 def test():
     yield 0
     with atomic() << _:
         yield 2
     with atomic() << _:
         yield 3
     with atomic() << _:
         yield 4
     yield 1
예제 #3
0
파일: example.py 프로젝트: denz/swarm
def squares_of_range(x):
    for i in range(1, x):
        with atomic() << _:
            # this runs inside `multiprocesing.Pool` and transparently 
            # takes `i` variable from outer world
            yield i*i
            #internally required modules are passed inside too
            time.sleep(round(random.random(), 3))
예제 #4
0
def status(*urls):
    with atomic(*urls) << _:
        yield (transport.status_code, transport.url, "set-cookie" in transport.headers.keys())
        with Http.context("http://google.com.ua/"):
            yield (transport.status_code, transport.url, "set-cookie" in transport.headers.keys())
        with Http.context("http://google.com.ua/"):
            yield (transport.status_code, transport.url, "set-cookie" in transport.headers.keys())
        with Http.context("http://google.com.ua/"):
            yield (transport.status_code, transport.url, "set-cookie" in transport.headers.keys())
예제 #5
0
파일: test_atomic.py 프로젝트: denz/swarm
        def test():
            yield 0
            with atomic() << _:
                yield 2
                with atomic() << _:
                    yield 5
                with atomic() << _:
                    yield 6

            with atomic() << _:
                yield 3
                with atomic() << _:
                    yield 7
                with atomic() << _:
                    yield 8
            with atomic() << _:
                yield 4
                with atomic() << _:
                    yield 9
                with atomic() << _:
                    yield 10

            yield 1
예제 #6
0
파일: test_state.py 프로젝트: denz/swarm
def subgenerator(value):
    with atomic(value) << _:
        yield value + 100