diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2008-01-23 18:51:33 -0500 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2008-01-23 18:51:33 -0500 |
commit | 33c6e4013874878f05eec593d69e8afdeaae212b (patch) | |
tree | e84879dd215ac90d20822ab0574dc1ab99b7ed8a /func/utils.py | |
parent | 19e4d1ba808cbbe95568271a5b0075b8422e4fb6 (diff) | |
download | func-33c6e4013874878f05eec593d69e8afdeaae212b.tar.gz func-33c6e4013874878f05eec593d69e8afdeaae212b.tar.xz func-33c6e4013874878f05eec593d69e8afdeaae212b.zip |
Working on async error handling, lots more to do...
(If it hits no exceptions, returns are right, it's the partial error case to deal with next...)
Diffstat (limited to 'func/utils.py')
-rwxr-xr-x | func/utils.py | 41 |
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 + + + |