Author: dmeyer
Date: Fri Jan 18 15:27:35 2008
New Revision: 2982
Log:
Rename exception in InProgress into throw and exception_handler into exception
Modified:
trunk/base/API_CHANGES.txt
trunk/base/src/notifier/async.py
trunk/base/src/notifier/sockets.py
trunk/base/src/notifier/thread.py
trunk/base/src/notifier/yieldfunc.py
trunk/base/src/rpc.py
trunk/beacon/bin/beacon-mount
trunk/popcorn/src/backends/mplayer/player.py
Modified: trunk/base/API_CHANGES.txt
==============================================================================
--- trunk/base/API_CHANGES.txt (original)
+++ trunk/base/API_CHANGES.txt Fri Jan 18 15:27:35 2008
@@ -24,7 +24,9 @@
4. Renamed Thread to ThreadCallback. The class has no signals anymore
and the start function is now __call__ and it will return an
- InProgress object
-
+ InProgress object.
+5. Rename exception_handler in InProgress into exception and the
+ exception callback function to throw. Add a convenience function
+ connect_both.
Modified: trunk/base/src/notifier/async.py
==============================================================================
--- trunk/base/src/notifier/async.py (original)
+++ trunk/base/src/notifier/async.py Fri Jan 18 15:27:35 2008
@@ -46,7 +46,7 @@
"""
An InProgress class used to return from function calls that need more time
to continue. It is possible to connect to an object of this class like
- Signals. The memeber 'exception_handler' is a second signal to get
+ Signals. The member 'exception' is a second signal to get
notification of an exception raised later.
"""
class Progress(Signal):
@@ -101,7 +101,7 @@
Create an InProgress object.
"""
Signal.__init__(self)
- self.exception_handler = Signal()
+ self.exception = Signal()
self.is_finished = False
self.status = None
@@ -134,7 +134,7 @@
if isinstance(result, InProgress):
# we are still not finished, register to this result
result.connect(self.finished)
- result.exception_handler.connect(self.exception)
+ result.exception.connect(self.throw)
return
# store result
self.is_finished = True
@@ -144,15 +144,15 @@
self.emit_when_handled(result)
# cleanup
self._callbacks = []
- self.exception_handler = None
+ self.exception = None
- def exception(self, e):
+ def throw(self, e):
"""
This function should be called when the creating function is
done because it raised an exception.
"""
- if self.exception_handler.count() == 0:
+ if self.exception.count() == 0:
if hasattr(e, '_exc_info'):
# Exception info set internally, so display traceback from
that.
trace = ''.join(traceback.format_exception(*e._exc_info))
@@ -165,10 +165,10 @@
self.is_finished = True
self._exception = e
# emit signal
- self.exception_handler.emit_when_handled(e)
+ self.exception.emit_when_handled(e)
# cleanup
self._callbacks = []
- self.exception_handler = None
+ self.exception = None
def __call__(self, *args, **kwargs):
@@ -200,3 +200,11 @@
will be emited only once.
"""
return Signal._connect(self, callback, args, kwargs, True, weak, pos)
+
+
+ def connect_both(self, finished, exception):
+ """
+ Connect a finished and an exception callback without extra arguments.
+ """
+ self.connect(finished)
+ self.exception.connect(exception)
Modified: trunk/base/src/notifier/sockets.py
==============================================================================
--- trunk/base/src/notifier/sockets.py (original)
+++ trunk/base/src/notifier/sockets.py Fri Jan 18 15:27:35 2008
@@ -181,8 +181,7 @@
cb = Callback(lambda res, x: x.append(res), result_holder)
else:
cb = self.signals["connected"].emit
- in_progress.connect(cb)
- in_progress.exception_handler.connect(cb)
+ in_progress.connect_both(cb, cb)
if async != None:
return
Modified: trunk/base/src/notifier/thread.py
==============================================================================
--- trunk/base/src/notifier/thread.py (original)
+++ trunk/base/src/notifier/thread.py Fri Jan 18 15:27:35 2008
@@ -81,8 +81,7 @@
self._sync_return = result
if isinstance(self._sync_return, InProgress):
if not self._sync_return.is_finished:
- self._sync_return.connect(self._set_result)
-
self._sync_return.exception_handler.connect(self._set_exception)
+ self._sync_return.connect_both(self._set_result,
self._set_exception)
return
self._sync_return = self._sync_return()
self._wakeup()
@@ -146,7 +145,7 @@
MainThreadCallback(self.finished, self._callback())()
except Exception, e:
e._exc_info = sys.exc_info()
- MainThreadCallback(self.exception, e)()
+ MainThreadCallback(self.throw, e)()
self._callback = None
@@ -190,7 +189,7 @@
t.setDaemon(self._daemon)
# connect thread.join to the InProgress
async.connect(t.join)
- async.exception_handler.connect(t.join)
+ async.exception.connect(t.join)
# start the thread
t.start()
return async
Modified: trunk/base/src/notifier/yieldfunc.py
==============================================================================
--- trunk/base/src/notifier/yieldfunc.py (original)
+++ trunk/base/src/notifier/yieldfunc.py Fri Jan 18 15:27:35 2008
@@ -174,8 +174,7 @@
def _connect(self, callback):
- self._in_progress.connect(callback)
- self._in_progress.exception_handler.connect(callback)
+ self._in_progress.connect_both(callback, callback)
def __call__(self, *args, **kwargs):
@@ -235,7 +234,7 @@
result = None
except Exception, e:
e._exc_info = sys.exc_info()
- self.exception(e)
+ self.throw(e)
return False
if result == YieldContinue:
return True
Modified: trunk/base/src/rpc.py
==============================================================================
--- trunk/base/src/rpc.py (original)
+++ trunk/base/src/rpc.py Fri Jan 18 15:27:35 2008
@@ -448,7 +448,7 @@
payload = self._callbacks[function](*args, **kwargs)
if isinstance(payload, kaa.InProgress):
payload.connect(self._send_delayed_answer, seq, 'RETN')
-
payload.exception_handler.connect(self._send_delayed_exception, seq, 'EXCP')
+ payload.exception.connect(self._send_delayed_exception,
seq, 'EXCP')
return True
packet_type = 'RETN'
except (SystemExit, KeyboardInterrupt):
@@ -480,7 +480,7 @@
if callback is None:
return True
del self._rpc_in_progress[seq]
- callback.exception(error)
+ callback.throw(error)
return True
log.error('unknown packet type %s', type)
Modified: trunk/beacon/bin/beacon-mount
==============================================================================
--- trunk/beacon/bin/beacon-mount (original)
+++ trunk/beacon/bin/beacon-mount Fri Jan 18 15:27:35 2008
@@ -149,6 +149,6 @@
kaa.utils.daemonize(stdout = logfile)
thread = kaa.ThreadCallback(fs.main)
- thread().exception_handler.connect(lambda dummy: kaa.main.stop())
+ thread().exception.connect(lambda dummy: kaa.main.stop())
kaa.main.run()
Modified: trunk/popcorn/src/backends/mplayer/player.py
==============================================================================
--- trunk/popcorn/src/backends/mplayer/player.py (original)
+++ trunk/popcorn/src/backends/mplayer/player.py Fri Jan 18 15:27:35 2008
@@ -92,8 +92,7 @@
async = kaa.ThreadCallback(_get_mplayer_info, path, None, mtime)()
# ThreadCallback class ensures the callbacks get invoked in the
main
# thread.
- async.connect(callback)
- async.exception_handler.connect(callback)
+ async.connect_both(callback, callback)
return None
# At this point we're running in a thread.
-------------------------------------------------------------------------
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