>> @asyncio.coroutine >> def recorder(): >> dialog = [] >> while True: >> sent = yield dialog >> if sent is not None: >> name, things = sent >> dialog.append(f'{name} says : {things}') >This is not an asyncio coroutine. This is just a normal generator that > you're sending to. So you should probably remove the decorator to > prevent confusion. For that matter I'm not really sure why this isn't > just a class with synchronous "add" and "get" methods.
Yeah it's true. I would just instantiate it, send to it and ask for a result. To pass it to next to start it and to retrieve a value is not really explicit. [...] >>It works well, but I was wondering if I could turn recorder into a new style >>coroutine... >Why? It doesn't do anything asynchronously. Hey, you're right... I was just, you know... "Async is so cool, let's just async everything!" >If it were a class, then you could make the individual methods be > coroutines if desired and await those. Thanks for your advise Ian! -- https://mail.python.org/mailman/listinfo/python-list