def end(self): try: SweepController.end(self) except AssertionError: return # In case the sweep is too fast, ensure that the user has some time to see the dialog. span = time() - self.sweep_start_time if span < self.stall_time: sleep(self.stall_time - span) wx.CallAfter(self.timer.Stop) wx.CallAfter(self.Destroy)