Here are the examples of the python api aiohttp.streams.DataQueue taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
3
Example 1
Project: aiohttp Source File: test_streams_35.py
async def test_data_queue_empty(loop):
"""Tests that async looping yields nothing if nothing is there"""
buffer = streams.DataQueue(loop=loop)
buffer.feed_eof()
async for _ in buffer: # NOQA
assert False
3
Example 2
Project: aiohttp Source File: test_streams_35.py
async def test_data_queue_items(loop):
"""Tests that async looping yields objects identically"""
buffer = streams.DataQueue(loop=loop)
items = [object(), object()]
buffer.feed_data(items[0], 1)
buffer.feed_data(items[1], 1)
buffer.feed_eof()
item_iter = iter(items)
async for item in buffer:
assert item is next(item_iter, None)
pytest.raises(StopIteration, next, item_iter)
0
Example 3
def setUp(self):
self.loop = asyncio.new_event_loop()
asyncio.set_event_loop(None)
self.buffer = streams.DataQueue(loop=self.loop)