code: def add_hook(self, name, callback, prio=0):
          
          hook_list = self._hooks.get(name, [])
  
          add = (lambda *args, **kwargs: self._exception_free_callback(callback, *args, **kwargs)), -prio
          pos = bisect.bisect_right(list(x[1] for x in hook_list), -prio)
          hook_list[pos:pos] = [add]
  
          self._hooks[name] = hook_list
docs: Add a new hook that can be called with the call_hook function.
              `prio` is the priority. Higher priority hooks are called before lower priority ones.
              This function does not enforce a particular order between hooks with the same priorities.