nasa/trick

TrickOps: Protect for divide by zero in progress bar computation

ddj116 opened this issue · 0 comments

First noticed in testing the unit sims that ship with the CML project, the traceback when it occurs looks like this:

Traceback (most recent call last):
  File "/deps/trick/share/trick/trickops/WorkflowCommon.py", line 801, in execute_jobs
    curses.wrapper(execute)
  File "/usr/lib64/python3.6/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/deps/trick/share/trick/trickops/WorkflowCommon.py", line 745, in execute
    job.get_status_string() + '\n\n', color)
  File "/deps/trick/share/trick/trickops/WorkflowCommon.py", line 329, in get_status_string
    return self._running_string()
  File "/deps/trick/share/trick/trickops/TrickWorkflow.py", line 1499, in _running_string
    self._connected_bar())
  File "/deps/trick/share/trick/trickops/TrickWorkflow.py", line 1543, in _connected_bar
    progress = self._tics.value / self._terminate_time.value
ZeroDivisionError: float division by zero

Unclear under what conditions this can happen, probably when a small unit sim is able to connect to the var server before time advances, which I'm guessing is rare. Even without understanding how it can occur, the resolution is probably to check for divide by zero in the computation of progress so it's not possible.

Trick Team - I can tackle this issue when I've got the bandwidth.