docs: def execute_task(task_id,
                   verbosity=None,
                   runmode='run',
                   sigmode=None,
                   monitor_interval=5,
                   resource_monitor_interval=60):
      '''Execute single or master task, return a dictionary'''
      tf = TaskFile(task_id)
  
      # this will automatically create a pulse file
      tf.status = 'running'
      # write result file
      try:
          signal.signal(signal.SIGTERM, signal_handler)
          res = _execute_task(task_id, verbosity, runmode, sigmode,
                              monitor_interval, resource_monitor_interval)
      except KeyboardInterrupt:
          tf.status = 'aborted'
          raise
      except ProcessKilled:
          tf.status = 'aborted'
          raise ProcessKilled('task interrupted')
      finally:
          signal.signal(signal.SIGTERM, signal.SIG_DFL)
  
      if res['ret_code'] != 0 and 'exception' in res:
          with open(
                  os.path.join(
                      os.path.expanduser('~'), '.sos', 'tasks', task_id + '.err'),
                  'a') as err:
              err.write(f'Task {task_id} exits with code {res["ret_code"]}')
  
      if res.get('skipped', False):
          # a special mode for skipped to set running time to zero
          tf.status = 'skipped'
      else:
          tf.add_outputs()
          sig = res.get('signature', {})
          res.pop('signature', None)
          tf.add_result(res)
          if sig:
              tf.add_signature(sig)
          # **after** result file is created, remove other files
          #
          # NOTE: if the pulse is not removed. When another sos process checkes
          # the task is started very quickly so the task has satus 'pending',
          # the task might be considered already running.
          tf.status = 'completed' if res['ret_code'] == 0 else 'failed'
  
      return res['ret_code']