[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [nyx/master] Stacktrace due to negative uptime



commit 08eec6f9067538778264eb952097ef982e2b4bc0
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Wed Jul 5 08:35:02 2017 -0700

    Stacktrace due to negative uptime
    
    Great catch from dgoulet. Sidestepping this is trivial and something we
    defintely want to do since there's edge cases this can arise in. For
    instance...
    
      * User pauses nyx's interface.
      * User quits tor then restarts the process.
      * User connects nyx to the new process.
    
    Since we're paused the 'now' is then before the startup time of the process,
    causing this to be negative. Needless to say this is a really weird edge case
    and not sure it would even happen when paused. None the less might as well code
    defenseively so we don't stacktrace like this...
    
      Traceback (most recent call last):
        File "/usr/local/bin/nyx", line 14, in <module>
          nyx.main()
        ...
        File "/usr/local/lib/python2.7/dist-packages/nyx/panel/header.py", line 169, in _draw
          _draw_resource_usage(subwindow, left_width, 0, right_width, vals, self._pause_time)
        File "/usr/local/lib/python2.7/dist-packages/nyx/panel/header.py", line 389, in _draw_resource_usage
          uptime = stem.util.str_tools.short_time_label(now - vals.start_time)
        File "/usr/local/lib/python2.7/dist-packages/stem/util/str_tools.py", line 417, in short_time_label
          raise ValueError("Input needs to be a non-negative integer, got '%i'" % seconds)
      ValueError: Input needs to be a non-negative integer, got '-114'
    
    More likely dgoulet is hitting another bug too where we detect the wrong
    startup time for the tor process.
---
 nyx/panel/header.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nyx/panel/header.py b/nyx/panel/header.py
index 63a4f86..d3e7454 100644
--- a/nyx/panel/header.py
+++ b/nyx/panel/header.py
@@ -386,7 +386,7 @@ def _draw_resource_usage(subwindow, x, y, width, vals, pause_time):
     else:
       now = time.time()
 
-    uptime = stem.util.str_tools.short_time_label(now - vals.start_time)
+    uptime = stem.util.str_tools.short_time_label(max(0, now - vals.start_time))
   else:
     uptime = ''
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits