File: py3_test_core.py

package info (click to toggle)
python-streamz 0.6.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 824 kB
  • sloc: python: 6,714; makefile: 18; sh: 18
file content (28 lines) | stat: -rw-r--r-- 561 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# flake8: noqa
import asyncio
from time import time
from distributed.utils_test import inc  # noqa

from streamz import Stream


def test_await_syntax():  # noqa
    L = []

    async def write(x):
        await asyncio.sleep(0.1)
        L.append(x)

    async def f():
        source = Stream(asynchronous=True)
        source.map(inc).buffer(3).sink(write)

        start = time()
        for x in range(6):
            await source.emit(x)
        stop = time()

        assert 0.2 < stop - start < 0.4
        assert 2 <= len(L) <= 4

    asyncio.run(f())