aboutsummaryrefslogtreecommitdiff
path: root/rpkid/rpki/http.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2011-10-04 18:06:44 +0000
committerRob Austein <sra@hactrn.net>2011-10-04 18:06:44 +0000
commit83524080bba998ea1cbe3b7ae25d0b798f0b9ace (patch)
tree075cee18ce029c65069bf2c83fd1ea9677e609cb /rpkid/rpki/http.py
parent611653c06120d21dc326e7d97d51b45ddebbf297 (diff)
Rework http_queue exception handling not to drop the event chain if
callback handler throws an exception, eg, due to CMS validation failure. This closes #94. svn path=/rpkid/rpki/http.py; revision=4009
Diffstat (limited to 'rpkid/rpki/http.py')
-rw-r--r--rpkid/rpki/http.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/rpkid/rpki/http.py b/rpkid/rpki/http.py
index 7513cc3f..1638449a 100644
--- a/rpkid/rpki/http.py
+++ b/rpkid/rpki/http.py
@@ -908,19 +908,30 @@ class http_queue(object):
self.log("No caller. THIS SHOULD NOT HAPPEN. Dropping result %r" % result, rpki.log.warn)
return
- try:
- if isinstance(result, http_response):
+ assert isinstance(result, http_response) or isinstance(result, Exception)
+
+ if isinstance(result, http_response):
+ try:
self.log("Returning result %r to caller" % result)
req.callback(result.body)
- else:
- assert isinstance(result, Exception)
+ except (rpki.async.ExitNow, SystemExit):
+ raise
+ except Exception, e:
+ result = e
+
+ if isinstance(result, Exception):
+ try:
self.log("Returning exception %r to caller: %s" % (result, result), rpki.log.warn)
req.errback(result)
- except (rpki.async.ExitNow, SystemExit):
- raise
- except:
- self.log("Unhandled exception from callback")
- rpki.log.traceback()
+ except (rpki.async.ExitNow, SystemExit):
+ raise
+ except:
+ #
+ # If we get here, we may have lost the event chain. Not
+ # obvious what we can do about it at this point.
+ #
+ self.log("Exception in exception callback", rpki.log.warn)
+ rpki.log.traceback()
self.log("Queue: %r" % self.queue)