tessl install tessl/pypi-asyncstdlib@3.13.0The missing async toolbox - re-implements functions and classes of the Python standard library to make them compatible with async callables, iterables and context managers
Agent Success
Agent success rate when using this tile
84%
Improvement
Agent success rate improvement when using this tile compared to baseline
3.36x
Baseline
Agent success rate without this tile
25%
Build a data processing utility that merges multiple async data streams of potentially different lengths into a unified output format.
You need to implement a function that processes multiple async data streams and combines them into a single list of records. Each stream may have a different number of items, and you must handle this gracefully by filling in missing values.
The function should accept:
Return a list where each element contains the corresponding items from all streams at that position. When a stream is exhausted, use the provided default value for that stream's position in subsequent records.
Given three async streams [1, 2], ['a', 'b', 'c'], and [True, False] with fill value None, the result should be [(1, 'a', True), (2, 'b', False), (None, 'c', None)]. @test
Given two async streams [] and [10, 20] with fill value "N/A", the result should be [("N/A", 10), ("N/A", 20)]. @test
Given two async streams ['x', 'y', 'z'] and [1, 2, 3] with fill value 0, the result should be [('x', 1), ('y', 2), ('z', 3)]. @test
@generates
async def merge_streams(*streams, fill_value):
"""
Merge multiple async iterables into a list of tuples.
Args:
*streams: Variable number of async iterables to merge
fill_value: Value to use when a stream is exhausted
Returns:
List of tuples containing items from all streams
"""
passProvides async-compatible versions of standard library functions for working with async iterables.