wolph / python-progressbar

Progressbar 2 - A progress bar for Python 2 and Python 3 - "pip install progressbar2"
http://progressbar-2.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
860 stars 102 forks source link

printing randomly when checking if it's pickable #263

Closed brando90 closed 2 years ago

brando90 commented 2 years ago

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

related:

mmckerns commented 2 years ago

CC'ing myself.

wolph commented 2 years ago

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 commented 2 years ago

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 :)