aboutsummaryrefslogtreecommitdiff
path: root/rpkid/rpki/https.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2009-12-02 01:22:13 +0000
committerRob Austein <sra@hactrn.net>2009-12-02 01:22:13 +0000
commit1952ab781a8bc5d4c17ccc0af6dd259fbf40c379 (patch)
tree8360f335ae18bb80f482139443b682935e25d46c /rpkid/rpki/https.py
parent088cfa86b40fa619bca7cb2032369ab1ff434701 (diff)
Implement deferred action queue separate from timers.
svn path=/rpkid/rpki/async.py; revision=2888
Diffstat (limited to 'rpkid/rpki/https.py')
-rw-r--r--rpkid/rpki/https.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/rpkid/rpki/https.py b/rpkid/rpki/https.py
index 091ca752..ed1f8546 100644
--- a/rpkid/rpki/https.py
+++ b/rpkid/rpki/https.py
@@ -645,16 +645,21 @@ class http_queue(object):
self.queue.extend(requests)
def restart(self):
- if self.client is None:
- client = http_client(self, self.hostport, cert = self.cert, key = self.key, ta = self.ta)
- self.log("Attaching client %r" % client)
- self.client = client
- self.client.start()
- elif self.client.state == "idle":
- self.log("Sending request to existing client %r" % self.client)
- self.send_request()
- else:
- self.log("Client %r exists in state %r" % (self.client, self.client.state))
+ try:
+ if self.client is None:
+ client = http_client(self, self.hostport, cert = self.cert, key = self.key, ta = self.ta)
+ self.log("Attaching client %r" % client)
+ self.client = client
+ self.client.start()
+ elif self.client.state == "idle":
+ self.log("Sending request to existing client %r" % self.client)
+ self.send_request()
+ else:
+ self.log("Client %r exists in state %r" % (self.client, self.client.state))
+ except (rpki.async.ExitNow, SystemExit):
+ raise
+ except Exception, e:
+ self.return_result(e)
def send_request(self):
if self.queue:
@@ -737,7 +742,7 @@ def client(msg, client_key, client_cert, server_ta, url, callback, errback):
if debug_http:
rpki.log.debug("Scheduling connection startup for %r" % request)
- rpki.async.timer(client_queues[hostport].restart, errback).set(None)
+ rpki.async.defer(client_queues[hostport].restart)
def server(handlers, server_key, server_cert, port, host ="", client_ta = (), dynamic_https_trust_anchor = None):
"""