Home > Enterprise >  How to show status in a very slow loop in python
How to show status in a very slow loop in python

Time:09-02

I want to show status every second in a very slow loop in python code, e.g.

for i in range(100):
    sleep(1000000) # think there is a very slow job

    # I want to show status in console every second
    # to know if the job stop or not

The output image is, e.g.

$ python somejob.py
> 2022-09-02 13:04:10 | Status: running... 

and the output updates every second, e.g.

$ python somejob.py
> 2022-09-02 13:04:11 | Status: running... 
$ python somejob.py
> 2022-09-02 13:04:12 | Status: running... 
$ python somejob.py
> 2022-09-02 13:04:13 | Status: running... 

Any idea will by helpful. Thx!!!

CodePudding user response:

I think what you're looking for is someting like the tqdm library: enter image description here

  • Related