Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure with asyncio #125

Closed
RobinFrcd opened this issue Jan 14, 2022 · 1 comment
Closed

Failure with asyncio #125

RobinFrcd opened this issue Jan 14, 2022 · 1 comment

Comments

@RobinFrcd
Copy link

Running multiple progress in different asycio tasks fails:

import asyncio
from alive_progress import alive_it


async def progress1():
    for i in alive_it(range(10), title="p1"):
        print(f"p1 {i}")
        await asyncio.sleep(1)


async def progress2():
    for i in alive_it(range(25), title="p2"):
        print(f"p2 {i}")
        await asyncio.sleep(0.5)


def main():
    loop = asyncio.get_event_loop()
    loop.create_task(progress1())
    loop.create_task(progress2())
    loop.run_forever()


if __name__ == "__main__":
    main()
on 0: p1 0
on 0: Task exception was never retrieved
      future: <Task finished name='Task-2' coro=<progress2() done, defined at maintest.py:11> exception=TypeError("unhashable type: 'types.SimpleNamespace'")>
      Traceback (most recent call last):
        File "maintest.py", line 13, in progress2
          print(f"p2 {i}")
        File ".../python3.9/site-packages/alive_progress/core/hook_manager.py", line 35, in write
          buffer = buffers[stream]
      TypeError: unhashable type: 'types.SimpleNamespace'
on 1: p1 1
on 2: p1 2
on 3: p1 3
on 4: p1 4
on 5: p1 5
on 6: p1 6
on 7: p1 7
on 8: p1 8
on 9: p1 9
p1 |████████████████████████████████████████| 10/10 [100%] in 10.1s (0.99/s)
@rsalmei
Copy link
Owner

rsalmei commented Jan 14, 2022

Hello.
Yes, it is a known fact that alive-progress does not support multiple concurrent instances.
It could be implemented someday, but it is very hard. See #20 and #75 and #42 and #124.

Edit: You could in this case create one on the main thread, and monitor the flow of completed tasks. 👍

Closing this one, to keep this request on the older ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants