From c09d14e9e4a8d5f1f1225d02777ce9531bf3923c Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Tue, 15 Jun 2021 11:57:00 +0200 Subject: [PATCH] split a method in two, some tests on callback performance --- kabuki/director.py | 11 +++++++++-- main.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kabuki/director.py b/kabuki/director.py index 3860ee2..8c0e339 100644 --- a/kabuki/director.py +++ b/kabuki/director.py @@ -1,3 +1,4 @@ +#from functools import partial from random import choice from bokeh.layouts import column @@ -28,19 +29,25 @@ class Director: def periodic_update(self): for func in self.updates: func() +# self.doc.add_next_tick_callback(func) #TODO: would this be an improvement? def do_add_pvs(self, attr, old, new): if not new: return # do not trigger on the following value reset self.sp_add_pvs.value = "" print(f"CB Add PV: attribute \"{attr}\" changed from \"{old}\" to \"{new}\"") + self.add_pvs(new) +# self.doc.add_next_tick_callback(partial(self.add_pvs, new)) #TODO: would this be an improvement? + + + def add_pvs(self, new): new = new.upper() # PV names are all upper case grid = break_apart(new) print(normalized_string(grid)) - self.add_pvs(grid) + self.add_pvs_grid(grid) - def add_pvs(self, pvnames_grid): + def add_pvs_grid(self, pvnames_grid): for pvnames in reversed(pvnames_grid): pvs_row = self.make_pvs_row(pvnames) if not pvs_row.children: diff --git a/main.py b/main.py index c9481f3..12bbfa5 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ from kabuki.director import Director app = Director() app.doc.add_periodic_callback(print_caches, 10000) -app.add_pvs([["MTEST:RAND0"], ["MTEST:ARR", "MTEST:CHAN-IMAGE:FPICTURE"]]) +app.add_pvs_grid([["MTEST:RAND0"], ["MTEST:ARR", "MTEST:CHAN-IMAGE:FPICTURE"]])