dbrattli / aioreactive

Async/await reactive tools for Python 3.11+
MIT License
350 stars 24 forks source link

from_iterable crashes with streams of tuples #14

Closed juanjovazquez closed 3 years ago

juanjovazquez commented 6 years ago

It seems that debug code is not able to format tuples and namedtuples properly. A snippet that reproduces the problem:

import asyncio
from aioreactive.core import subscribe, AsyncAnonymousObserver
from aioreactive.core import AsyncObservable
from collections import namedtuple

async def main():
    Foo = namedtuple("Foo", ["name", "value"])
    foos = [Foo("one", 1), Foo("two", 2)]
    xs = AsyncObservable.from_iterable(foos)

    async def mysink(value):
        print(value)

    await subscribe(xs, AsyncAnonymousObserver(mysink))

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
    loop.close()
AsyncAnonymousObserver exception was never retrieved
future: <AsyncAnonymousObserver finished 
exception=TypeError('not all arguments converted during string formatting',)>
Traceback (most recent call last):
  File ".../lib/python3.6/site-packages/aioreactive/operators/from_iterable.py", line 32, in worker
    log.debug("sync_worker. asending: %s" % value)
TypeError: not all arguments converted during string formatting