Mercurial > pydertron
changeset 7:2117265e4dfe
Fixed some threading issues.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Thu, 10 Sep 2009 01:11:01 -0700 |
parents | 97adec8c8127 |
children | fb0b161542b1 |
files | pydertron.py |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pydertron.py Thu Sep 10 01:04:04 2009 -0700 +++ b/pydertron.py Thu Sep 10 01:11:01 2009 -0700 @@ -5,6 +5,7 @@ import traceback import weakref import types +import atexit import pydermonkey @@ -16,7 +17,7 @@ # Default interval, in seconds, that the operation callbacks are # triggered at. - DEFAULT_INTERVAL = 0.25 + DEFAULT_INTERVAL = 0.15 def __init__(self, interval=DEFAULT_INTERVAL): threading.Thread.__init__(self) @@ -24,7 +25,6 @@ self._stop = threading.Event() self._contexts = [] self.interval = interval - self.setDaemon(True) def add_context(self, cx): self._lock.acquire() @@ -48,6 +48,7 @@ if cx: new_list.append(weakcx) cx.trigger_operation_callback() + del cx self._contexts = new_list finally: self._lock.release() @@ -55,6 +56,7 @@ # Create a global watchdog. watchdog = ContextWatchdogThread() watchdog.start() +atexit.register(watchdog.join) class InternalError(BaseException): """