rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.53k stars 206 forks source link

cannot use with `dill` #217

Closed weaver9651 closed 1 year ago

weaver9651 commented 1 year ago

Hello. When I use alive-progress with dill package, an error occurs. Here's the code that I tried.

import time

import dill
from alive_progress import alive_bar

total_len = 1000
with alive_bar(total_len) as bar:
    for _ in range(0, total_len):
        time.sleep(0.001)
        bar()

Please let me know if I missed something. Thank you.

TheTechRobo commented 1 year ago

What error occurs?

weaver9651 commented 1 year ago
Traceback (most recent call last):
  File "tmp.py", line 7, in <module>
    with alive_bar(total_len) as bar:
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/home/user/.virtualenvs/tmp/lib/python3.8/site-packages/alive_progress/core/progress.py", line 328, in __alive_bar
    start_monitoring()
  File "/home/user/.virtualenvs/tmp/lib/python3.8/site-packages/alive_progress/core/progress.py", line 190, in start_monitoring
    hook_manager.install()
  File "/home/user/.virtualenvs/tmp/lib/python3.8/site-packages/alive_progress/core/hook_manager.py", line 88, in install
    before_handlers.update({h: h.setStream(get_hook_for(h)) for h in handlers})
  File "/home/user/.virtualenvs/tmp/lib/python3.8/site-packages/alive_progress/core/hook_manager.py", line 88, in <dictcomp>
    before_handlers.update({h: h.setStream(get_hook_for(h)) for h in handlers})
  File "/usr/lib/python3.8/logging/__init__.py", line 1110, in setStream
    self.stream = stream
AttributeError: can't set attribute
rsalmei commented 1 year ago

Oh boy, dill's author has used a protected logging class, which is Python's last resort internal processing... 🤦‍♂️

image

But ok, I think I can ignore errors in there...

rsalmei commented 1 year ago

Release 3.0.1 fixes this.