Author: dmeyer
Date: Thu Feb 14 06:15:05 2008
New Revision: 3093
Log:
Add an execute function to InProgress to execute a non coroutine
function inside an InProgress object.
Modified:
trunk/base/src/notifier/async.py
Modified: trunk/base/src/notifier/async.py
==============================================================================
--- trunk/base/src/notifier/async.py (original)
+++ trunk/base/src/notifier/async.py Thu Feb 14 06:15:05 2008
@@ -32,6 +32,7 @@
__all__ = [ 'InProgress' ]
# python imports
+import sys
import logging
import traceback
import time
@@ -246,6 +247,21 @@
log.error('Unhandled %s exception:\n%s', cls.__name__, trace)
+ def execute(self, func, *args, **kwargs):
+ """
+ Execute the function and store the result or exception inside the
+ InProgress object. Returns self to support yield in a coroutine.
+ To yield a finished object call yield InProgress().execute(...)
+ """
+ try:
+ result = func(*args, **kwargs)
+ except:
+ self.throw(*sys.exc_info())
+ else:
+ self.finished(result)
+ return self
+
+
def is_finished(self):
"""
Return if the InProgress is finished.
-------------------------------------------------------------------------
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