diff options
Diffstat (limited to 'rpkid')
-rw-r--r-- | rpkid/rpki/irdbd.py | 7 | ||||
-rw-r--r-- | rpkid/rpki/left_right.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/pubd.py | 7 | ||||
-rw-r--r-- | rpkid/rpki/rpkid.py | 7 | ||||
-rw-r--r-- | rpkid/tests/yamltest.py | 22 |
5 files changed, 34 insertions, 11 deletions
diff --git a/rpkid/rpki/irdbd.py b/rpkid/rpki/irdbd.py index 60f6a549..a0fc0ec1 100644 --- a/rpkid/rpki/irdbd.py +++ b/rpkid/rpki/irdbd.py @@ -174,7 +174,12 @@ class main(object): if profile: import cProfile - cProfile.run("self.main()", profile) + prof = cProfile.Profile() + try: + prof.runcall(self.main) + finally: + prof.dump_stats(profile) + rpki.log.info("Dumped profile data to %s" % profile) else: self.main() diff --git a/rpkid/rpki/left_right.py b/rpkid/rpki/left_right.py index 04940ca1..122da9d3 100644 --- a/rpkid/rpki/left_right.py +++ b/rpkid/rpki/left_right.py @@ -699,7 +699,7 @@ class self_elt(data_elt): roa = rpki.rpkid.roa_obj(self.gctx, self.self_id, roa_request.asn, roa_request.ipv4, roa_request.ipv6) rpki.log.debug("Couldn't find existing ROA, created %r" % roa) if max_new_roas_at_once is not None and publisher.size > max_new_roas_at_once: - rpki.log.warn("Too many new ROAs (%d) in a single batch, returning early from update_roas() to avoid timeouts" % publisher.size) + rpki.log.warn("Too many new ROAs in a single batch, deferring processing some of them") stopped_early = True break else: diff --git a/rpkid/rpki/pubd.py b/rpkid/rpki/pubd.py index 0bf811db..7a00c172 100644 --- a/rpkid/rpki/pubd.py +++ b/rpkid/rpki/pubd.py @@ -98,7 +98,12 @@ class main(object): if self.profile: import cProfile - cProfile.run("self.main()", self.profile) + prof = cProfile.Profile() + try: + prof.runcall(self.main) + finally: + prof.dump_stats(self.profile) + rpki.log.info("Dumped profile data to %s" % self.profile) else: self.main() diff --git a/rpkid/rpki/rpkid.py b/rpkid/rpki/rpkid.py index 8c275688..b923b1a3 100644 --- a/rpkid/rpki/rpkid.py +++ b/rpkid/rpki/rpkid.py @@ -102,7 +102,12 @@ class main(object): if self.profile: import cProfile - cProfile.run("self.main()", self.profile) + prof = cProfile.Profile() + try: + prof.runcall(self.main) + finally: + prof.dump_stats(self.profile) + rpki.log.info("Dumped profile data to %s" % self.profile) else: self.main() diff --git a/rpkid/tests/yamltest.py b/rpkid/tests/yamltest.py index b946eebe..9902ad2e 100644 --- a/rpkid/tests/yamltest.py +++ b/rpkid/tests/yamltest.py @@ -327,11 +327,10 @@ class allocation(object): """ Write ROA CSV file. """ - group = self.name if self.is_root else self.parent.name f = self.csvout(fn) - for r in self.roa_requests: - f.writerows((p, r.asn, group) - for p in (r.v4 + r.v6 if r.v4 and r.v6 else r.v4 or r.v6 or ())) + for g1, r in enumerate(self.roa_requests): + f.writerows((p, r.asn, "G%08d%08d" % (g1, g2)) + for g2, p in enumerate((r.v4 + r.v6 if r.v4 and r.v6 else r.v4 or r.v6 or ()))) f.close() self.run_rpkic("load_roa_requests", fn) @@ -441,8 +440,12 @@ class allocation(object): Start a Python daemon and return a subprocess.Popen object representing the running daemon. """ - cmd = (prog, "-d", "-c", self.path("rpki.conf")) - log = os.path.splitext(os.path.basename(prog))[0] + ".log" + basename = os.path.splitext(os.path.basename(prog))[0] + cmd = [prog, "-d", "-c", self.path("rpki.conf")] + if profile and basename != "rootd": + cmd.append("--profile") + cmd.append(self.path(basename + ".prof")) + log = basename + ".log" p = subprocess.Popen(cmd, cwd = self.path(), stdout = open(self.path(log), "w"), @@ -491,8 +494,11 @@ pidfile = None keep_going = False skip_config = False flat_publication = False +profile = False -opts, argv = getopt.getopt(sys.argv[1:], "c:fhkp:s?", ["config=", "flat_publication", "help", "keep_going", "pidfile=", "skip_config"]) +opts, argv = getopt.getopt(sys.argv[1:], "c:fhkp:s?", + ["config=", "flat_publication", "help", "keep_going", + "pidfile=", "skip_config", "profile"]) for o, a in opts: if o in ("-h", "--help", "-?"): print __doc__ @@ -507,6 +513,8 @@ for o, a in opts: pidfile = a elif o in ("-s", "--skip_config"): skip_config = True + elif o == "--profile": + profile = True # We can't usefully process more than one YAML file at a time, so # whine if there's more than one argument left. |