I can’t figure out how to edit so I’ll reply instead.
I’ve fixed the example above by saving a reference to the document right after the button is pressed.
def _do_calc(self):
self.doc = curdoc() # Insert this line
self.param['do_stuff'].constant = True