Python 3 showing progressbar while subprocess.Popen

Have an interesting case I want to share and save for future.

One small problem in this system: https://github.com/trianglesis/BMC_TPL_IDE is showing when some process is running and was not hanged up.

Sometimes we need to run a huge amount of checks and tests and would be great to know if something hangs before killing it mannually.
I used different scenarios and mostly a module pregressbar2, and this is what I finally can compose:

  1. Make worker which will execute job sorf of randomly:
  2. Make process executor:

    1.  

Voilla! But there is still a small problem – this bar will update it’s state only when process post something in stdout. Between posts it will stay calm for random amount of time (as designed in worker). If I’ll update while or somehow try to make this loop faster – it becomes a deadlock. 

 

Next example is from: https://github.com/trianglesis/BMC_TPL_IDE/blob/master/bmc_tplpre/check/upload.py

Function: tests_executor.

In this example – bar works better, because It have a list of tests, so I can enumerate its len and config bar to show how much progress were already done.

But yes, it will update only each one itetarion, and till test run, for 600+ sec – it wouldn’t move.

 

So the problem solved, partially. 

Still wondering – how to make progressbar or spinner update constantly till process not die?

trianglesis

About trianglesis

Александр Брюндтзвельт - гений, филантроп, 100 гривен в кармане. Этот блог - "сток" моих мыслей и заметок. Достаточно одного взгляда на него, чтобы понять, что такой же бардак творится у меня в голове. Если вам этот бардак интересен - милости прошу.
Bookmark the permalink.

Comments are closed.