Author: dmeyer
Date: Fri Jan 18 14:06:32 2008
New Revision: 2978
Log:
move InProgressCallback to thread.ThreadCallback
Modified:
trunk/base/src/notifier/jobserver.py
trunk/base/src/notifier/thread.py
Modified: trunk/base/src/notifier/jobserver.py
==============================================================================
--- trunk/base/src/notifier/jobserver.py (original)
+++ trunk/base/src/notifier/jobserver.py Fri Jan 18 14:06:32 2008
@@ -40,7 +40,6 @@
# kaa notifier imports
from callback import Signal, Callback
from async import InProgress
-from thread import MainThreadCallback
import thread
# internal list of named threads
@@ -73,42 +72,6 @@
return decorator
-class InProgressCallback(InProgress):
- def __init__(self, callback, *args, **kwargs):
- InProgress.__init__(self)
- self._callback = Callback(callback, *args, **kwargs)
-
-
- def _execute(self):
- """
- Execute the callback. This function SHOULD be called __call__ but
- InProgress.__call__ returns the result. This is deprecated but
- still used.
- """
- if self._callback is None:
- return None
- try:
- MainThreadCallback(self.finished, self._callback())()
- except Exception, e:
- e._exc_info = sys.exc_info()
- MainThreadCallback(self.exception, e)()
- self._callback = None
-
-
- def active(self):
- """
- Return True if the callback is still waiting to be proccessed.
- """
- return self._callback is not None
-
-
- def stop(self):
- """
- Remove the callback from the thread schedule if still active.
- """
- self._callback = None
-
-
class NamedThreadCallback(Callback):
"""
A callback to run a function in a thread. This class is used by
@@ -126,7 +89,7 @@
def _create_job(self, *args, **kwargs):
cb = Callback._get_callback(self)
- job = InProgressCallback(cb, *args, **kwargs)
+ job = thread.ThreadInProgress(cb, *args, **kwargs)
job.priority = self.priority
if not _threads.has_key(self._thread):
_threads[self._thread] = _Thread(self._thread)
Modified: trunk/base/src/notifier/thread.py
==============================================================================
--- trunk/base/src/notifier/thread.py (original)
+++ trunk/base/src/notifier/thread.py Fri Jan 18 14:06:32 2008
@@ -127,6 +127,42 @@
return None
+class ThreadInProgress(InProgress):
+ def __init__(self, callback, *args, **kwargs):
+ InProgress.__init__(self)
+ self._callback = Callback(callback, *args, **kwargs)
+
+
+ def _execute(self):
+ """
+ Execute the callback. This function SHOULD be called __call__ but
+ InProgress.__call__ returns the result. This is deprecated but
+ still used.
+ """
+ if self._callback is None:
+ return None
+ try:
+ MainThreadCallback(self.finished, self._callback())()
+ except Exception, e:
+ e._exc_info = sys.exc_info()
+ MainThreadCallback(self.exception, e)()
+ self._callback = None
+
+
+ def active(self):
+ """
+ Return True if the callback is still waiting to be proccessed.
+ """
+ return self._callback is not None
+
+
+ def stop(self):
+ """
+ Remove the callback from the thread schedule if still active.
+ """
+ self._callback = None
+
+
class Thread(threading.Thread):
"""
Notifier aware wrapper for threads. When a thread is started, it is
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog