code: def _run_events(self, shutdown=False):
          
  
          # run task_start events, if not ran already
          if not self._ran_taskstart:
              self._ran_taskstart = True
              registration.run_event_hooks('task_start', self._task)
  
          # run events
          event = 'task_end' if shutdown else 'task_run'
          registration.run_event_hooks(event, self._task)
  
          # reclaim any subprocesses plugins may have forked
          try:
              os.waitpid(-1, os.P_NOWAIT)
          except OSError:
              pass
docs: Runs event hooks for registered event plugins.
  
              `shutdown`
                  Set to ``True`` to run task_end events;
                  otherwise, run task_run events.