summaryrefslogtreecommitdiffstats
path: root/func/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'func/utils.py')
-rwxr-xr-xfunc/utils.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/func/utils.py b/func/utils.py
index 4149885..140b761 100755
--- a/func/utils.py
+++ b/func/utils.py
@@ -14,7 +14,9 @@ import os
import string
import sys
import traceback
+import xmlrpclib
+REMOTE_CANARY = "***REMOTE_ERROR***"
# this is kind of handy, so keep it around for now
# but we really need to fix out server side logging and error
@@ -44,3 +46,42 @@ def daemonize(pidfile=None):
if pidfile is not None:
open(pidfile, "w").write(str(pid))
sys.exit(0)
+
+def remove_exceptions(results):
+ """
+ Used by forkbomb/jobthing to avoid storing exceptions in database
+ because you know those don't serialize so well :)
+ # FIXME: this needs cleanup
+ """
+
+ if results is None:
+ print "DEBUG: A"
+ return REMOTE_CANARY
+
+ if str(results).startswith("<Fault"):
+ print "DEBUG: B"
+ return REMOTE_CANARY
+
+ if type(results) == xmlrpclib.Fault:
+ print "DEBUG: C"
+ return REMOTE_CANARY
+
+ if type(results) == dict:
+ new_results = {}
+ for x in results.keys():
+ value = results[x]
+ # print "DEBUG: checking against: %s" % str(value)
+ if str(value).find("<Fault") == -1:
+ # there are interesting issues with the way it is imported and type()
+ # so that is why this hack is here. type(x) != xmlrpclib.Fault appears to miss some things
+ new_results[x] = value
+ else:
+ new_results[x] = REMOTE_CANARY
+ # print "DEBUG: removed exceptions = %s" % new_results
+ return new_results
+
+ print "DEBUG: removed exceptions = %s" % results
+ return results
+
+
+