Exemplo n.º 1
0
def simpleFunction4():
    async def someCoroutine():
        raise StopIteration

    try:
        run_async(someCoroutine())
    except RuntimeError:
        pass
Exemplo n.º 2
0
def simpleFunction4():
    async def foo():
        raise StopIteration

    try:
        run_async(foo())
    except RuntimeError:
        pass
Exemplo n.º 3
0
def simpleFunction4():
    async def foo():
        raise StopIteration

    try:
        run_async(foo())
    except RuntimeError:
        pass
Exemplo n.º 4
0
def simpleFunction7():
    async def foo():
        async for i in BadAsyncIter():
            print('never going to happen')

    try:
        run_async(foo())
    except TypeError:
        pass
Exemplo n.º 5
0
def simpleFunction7():
    async def someCoroutine():
        async for _i in BadAsyncIter():
            print("never going to happen")

    try:
        run_async(someCoroutine())
    except TypeError:
        pass
Exemplo n.º 6
0
def simpleFunction8():
    async def someCoroutine():
        return ("some", "thing")

    @types.coroutine
    def someDecoratorCoroutine():
        yield from someCoroutine()

    run_async(someDecoratorCoroutine())
Exemplo n.º 7
0
def simpleFunction8():
    async def bar():
        return ("some", "thing")

    @types.coroutine
    def foo():
        yield from bar()

    run_async(foo())
Exemplo n.º 8
0
def simpleFunction7():
    async def foo():
        async for i in BadAsyncIter():
            print('never going to happen')

    try:
        run_async(foo())
    except TypeError:
        pass
Exemplo n.º 9
0
def simpleFunction8():
    async def bar():
        return ("some", "thing")

    @types.coroutine
    def foo():
        yield from bar()

    run_async(foo())
Exemplo n.º 10
0
def simpleFunction3():
    async def f():
        result = []

        async for letter in AsyncIteratorWrapper("abcdefg"):
            result.append(letter)

        return result

    run_async(f())
Exemplo n.º 11
0
def simpleFunction3():
    async def f():
        result = []

        # Python 3.5 before 3.2 won't allow this.
        try:
            async for letter in AsyncIteratorWrapper("abcdefg"):
                result.append(letter)
        except TypeError:
            assert sys.version_info < (3,5,2)

        return result

    run_async(f())
Exemplo n.º 12
0
def simpleFunction3():
    async def f():
        result = []

        # Python 3.5 before 3.2 won't allow this.
        try:
            async for letter in AsyncIteratorWrapper("abcdefg"):
                result.append(letter)
        except TypeError:
            assert sys.version_info < (3, 5, 2)

        return result

    run_async(f())
Exemplo n.º 13
0
def simpleFunction3():
    def to_list(gen):
        async def iterate():
            res = []
            async for i in gen:
                res.append(i)
            return res

        return run_until_complete(iterate())

    async def run2():
        return to_list(gen2())

    run_async(run2())
Exemplo n.º 14
0
def simpleFunction3():
    def to_list(gen):
        async def iterate():
            res = []
            async for i in gen:
                res.append(i)
            return res

        return run_until_complete(iterate())


    async def run2():
        return to_list(gen2())

    run_async(run2())
Exemplo n.º 15
0
def simpleFunction1():
    async def gen1():
        try:
            yield
        except:  # pylint: disable=bare-except
            pass

    async def run():
        g = gen1()
        await g.asend(None)
        await g.asend(None)

    try:
        run_async(run())
    except StopAsyncIteration:
        pass
Exemplo n.º 16
0
def simpleFunction1():
    async def gen1():
        try:
            yield
        except:
            pass

    async def run():
            g = gen1()
            await g.asend(None)
            await g.asend(None)

    try:
        run_async(run())
    except StopAsyncIteration:
        pass
Exemplo n.º 17
0
def simpleFunction5():
    run_async(ClassWithAsyncMethod().async_method())
Exemplo n.º 18
0
def simpleFunction2():
    async def someCoroutine():
        return 7

    run_async(someCoroutine())
Exemplo n.º 19
0
def simpleFunction1():
    async def foo():
        return

    run_async(foo())
Exemplo n.º 20
0
def simpleFunction2():
    async def foo():
        return 7

    run_async(foo())
Exemplo n.º 21
0
def simpleFunction5():
    run_async(ClassWithAsyncMethod().async_method())
Exemplo n.º 22
0
def simpleFunction2():
    async def foo():
        return 7

    run_async(foo())
Exemplo n.º 23
0
def simpleFunction1():
    async def foo():
        return

    run_async(foo())