pydoit / doit

CLI task management & automation tool
http://pydoit.org
MIT License
1.85k stars 175 forks source link

No output from failed tasks when multiple processes are used #387

Closed alexandre-allard closed 3 years ago

alexandre-allard commented 3 years ago

Describe the bug

When running doit with --process 2 (or more), if an action fails, err and out attributes of the action are always empty in the reporter when captured. However it works well if not using multiple processes or if the task succeeds.

Here is a simple dodo.py file to reproduce:

import doit

DOIT_CONFIG = {
    "reporter": doit.reporter.JsonReporter,
}

def task__test_failure():
    return {
        "actions": [doit.action.CmdAction("mkdir")],
    }

Which gives, without --process 2:

{
  "tasks": [
    {
      "name": "_test_failure",
      "result": "fail",
      "out": "",
      "err": "mkdir: missing operand\nTry 'mkdir --help' for more information.\n",
      "error": "Command failed: 'mkdir' returned 1\n",
      "started": "2021-03-30 08:11:03.319472",
      "elapsed": 0.0035848617553710938
    }
  ],
  "out": "",
  "err": "mkdir: missing operand\nTry 'mkdir --help' for more information.\n"
}

And with it:

{
  "tasks": [
    {
      "name": "_test_failure",
      "result": "fail",
      "out": "",
      "err": "",
      "error": "Command failed: 'mkdir' returned 1\n",
      "started": "2021-03-30 08:11:12.858163",
      "elapsed": 0.0039060115814208984
    }
  ],
  "out": "",
  "err": ""
}

Environment

  1. OS: Ubuntu 20.04
  2. python version: 3.8.5
  3. doit version: 0.32.0
alexandre-allard commented 3 years ago

Another issue, not directly related to this one but it is the same part in the code, when the task fails, attributes are not updated with the pickled ones. Meaning that, for example, a failed task is always seen as not executed.