pydertron
changeset 8:fb0b161542b1
Improved performance of watchdog thread.
| author | Atul Varma <varmaa@toolness.com> |
|---|---|
| date | Thu Sep 10 10:43:25 2009 -0700 (2 years ago) |
| parents | 2117265e4dfe |
| children | a88d1cc4db92 |
| files | pydertron.py |
line diff
1.1 --- a/pydertron.py Thu Sep 10 01:11:01 2009 -0700
1.2 +++ b/pydertron.py Thu Sep 10 10:43:25 2009 -0700
1.3 @@ -1,6 +1,5 @@
1.4 import os
1.5 import sys
1.6 -import time
1.7 import threading
1.8 import traceback
1.9 import weakref
1.10 @@ -17,7 +16,7 @@
1.11
1.12 # Default interval, in seconds, that the operation callbacks are
1.13 # triggered at.
1.14 - DEFAULT_INTERVAL = 0.15
1.15 + DEFAULT_INTERVAL = 0.25
1.16
1.17 def __init__(self, interval=DEFAULT_INTERVAL):
1.18 threading.Thread.__init__(self)
1.19 @@ -39,7 +38,6 @@
1.20
1.21 def run(self):
1.22 while not self._stop.isSet():
1.23 - time.sleep(self.interval)
1.24 new_list = []
1.25 self._lock.acquire()
1.26 try:
1.27 @@ -52,6 +50,7 @@
1.28 self._contexts = new_list
1.29 finally:
1.30 self._lock.release()
1.31 + self._stop.wait(self.interval)
1.32
1.33 # Create a global watchdog.
1.34 watchdog = ContextWatchdogThread()
