From 8fed50130c18a7ee19eb7428350ff038cab538b6 Mon Sep 17 00:00:00 2001 From: scottsanderson Date: Mon, 20 Aug 2012 18:04:30 -0400 Subject: [PATCH] reset heartbeat count on enter/exit --- zipline/utils/timeout.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zipline/utils/timeout.py b/zipline/utils/timeout.py index 0310a208..2985222e 100644 --- a/zipline/utils/timeout.py +++ b/zipline/utils/timeout.py @@ -106,6 +106,7 @@ class heartbeat(object): # decorator doesn't have unexpected side-effects later. signal.setitimer(signal.ITIMER_REAL, 0, 0) signal.signal(signal.SIGALRM, signal.SIG_DFL) + self.count = 0 # Return the value of fn if it finished without tripping # an exception. This won't execute if the Timeout or any @@ -115,11 +116,13 @@ class heartbeat(object): def __enter__(self): # Set a timer to call our handler every N seconds. + self.count = 0 signal.signal(signal.SIGALRM, self.handler) signal.setitimer(signal.ITIMER_REAL, self.interval, self.interval) def __exit__(self, type, value, traceback): # Turn off the timer on exit. This will re-raise any exception raised # during execution of the with-block + self.count = 0 signal.setitimer(signal.ITIMER_REAL, 0, 0) signal.signal(signal.SIGALRM, signal.SIG_DFL)