Skip to content

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

Description

@magerkurth

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions