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

Elapsed (elapsed_td) time does not start at 0s. #103

Open
magerkurth opened this issue May 6, 2022 · 0 comments
Open

Elapsed (elapsed_td) time does not start at 0s. #103

magerkurth opened this issue May 6, 2022 · 0 comments

Comments

@magerkurth
Copy link

Hi,

system: dockerised ubuntu LTS, python 3.10.2, progress version 1.6

I am using the Bar class in different defined classes. Each class has a line similar to

self._progess_bar = Bar('Processing %(max)d image files:', suffix = '%(remaining)d left, %(eta_td)s left, %(elapsed_td)s elapsed')

The classes are independent and not inherited from each other.

When the object of the first class is calling self._progess_bar within the processing loop, "elapsed_td" starts at 0s.

When the object of the next class is executed, "elapsed_td" starts with the time elapsed from the object before.

I tried to encapsulate the bar calls in a "with" statements but still have the same issue. I also checked your code for class variables in regards to elapsed_td or a singleton definition, with could explain the problem. I hope you have more luck.

A code example:

from progress.bar import Bar
from time import sleep

class one():
    def __init__(self):
        self._progess_bar = Bar('Bar 1: Processing %(max)d files:', suffix = '%(remaining)d left, %(eta_td)s left, %(elapsed_td)s elapsed')

    def __call__(self):
        self._progess_bar.max=10
        for i in range(10):
            sleep(1)
            self._progess_bar.next()
        self._progess_bar.finish()


class two():
    def __init__(self):
        self._progess_bar = Bar('Bar 2: Processing %(max)d files:', suffix = '%(remaining)d left, %(eta_td)s left, %(elapsed_td)s elapsed')

    def __call__(self):
        self._progess_bar.max=10
        for i in range(10):
            sleep(1)
            self._progess_bar.next()
        self._progess_bar.finish()


obj1 = one()
obj2 = two()

obj1()
obj2()
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

1 participant