python-progressbar icon indicating copy to clipboard operation
python-progressbar copied to clipboard

printing randomly when checking if it's pickable

Open brando90 opened this issue 3 years ago • 2 comments

Description

when I try to check if objects that reference a bar is pickable I get random prints of progress bars. e.g.

dill.pickles(field_val)
N/A% (0 of N/A) |#        | Elapsed Time: 0:00:00 | ETA:  --:--:-- |   0.0 s/it
True

This doesn't seem correct to me.

Code

widgets = [
        progressbar.Percentage(),
        ' ', progressbar.SimpleProgress(format=f'({progressbar.SimpleProgress.DEFAULT_FORMAT})'),
        ' ', progressbar.Bar(),
        ' ', progressbar.Timer(), ' |',
        ' ', progressbar.ETA(), ' |',
        ' ', progressbar.AdaptiveTransferSpeed(unit='it'),
    ]
bar = progressbar.ProgressBar(widgets=widgets, max_value=progressbar.UnknownLength)
not dill.pickles(bar)

Versions

  • Python version: import sys; print(sys.version), import sys; print(sys.version) 3.9.7 (default, Sep 16 2021, 08:50:36) [Clang 10.0.0 ]
  • Python distribution/environment: Pip
  • Operating System: Mac
  • Package version: import progressbar; print(progressbar.__version__)
import progressbar; print(progressbar.__version__)
3.55.0

related:

  • https://github.com/WoLpH/python-progressbar/issues/263
  • https://github.com/uqfoundation/dill/issues/445
  • https://stackoverflow.com/questions/70762899/how-does-one-stop-progressbar-from-printing-eta-progress-when-checking-if-the

brando90 avatar Jan 18 '22 21:01 brando90

CC'ing myself.

mmckerns avatar Jan 19 '22 16:01 mmckerns

The random part makes me wonder a bit, that could be due to a timing issue but it's still a bit weird.

In any case, dill seems to call some functions that trigger the progressbar to run. My guess would be that pickle attempts to iterate the progressbar which logically triggers it because that is part of the expected API.

I would guess that making the progressbar pickleable would fix it, but I fear that could make for false promises. While most parts should be pickle-safe, I am not a 100% certain...

Is there any use for making the progressbar dill/pickle safe?

wolph avatar Jan 20 '22 02:01 wolph

The new beta release has a fix for the issue. I'm still testing it so I'm not entirely sure when it will be stable though :)

wolph avatar Nov 01 '22 23:11 wolph