Skip to content

undetected dependency loop or deadlock with run: when_changed #2302

Open
@jberkenbilt

Description

@jberkenbilt

Description

In the example Taskfile.yml below, running task "hangs" forever. Okay, I didn't actually wait forever. But it hangs for long enough for you to think it's in an infinite loop or deadlock. If you remove run: when_changed, you get what you would expect:

task: Maximum task call exceeded (1000) for task "default": probably an cyclic dep or infinite loop

but the presence of run: when_changed or run: once is preventing this check from triggering.

I'm not really sure what the right behavior should be. My first thought was that it there should be proper loop detection rather than reliance on call depth, though I think limiting call depth is still important. But then I thought, well, if x only runs once, I might think the sequence should be default -> x -> default: default tries to run x, which tries to run default, which doesn't run x because it's run: once. But of course x didn't actually ever run. It only got invoked. So...you could make run: once or run: when_changed consider the task to have been run once it was invoked even if it hasn't finished, but I feel like maybe proper loop and deadlock detection may be best. I haven't looked at the code, so this is all speculation. Take it or leave it. You know the code. :-)

Version

3.44.0

Operating system

multiple

Experiments Enabled

No response

Example Taskfile

version: '3'

tasks:
  default:
    deps:
      - x

  x:
    run: when_changed
    deps:
      - default

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: needs triageWaiting to be triaged by a maintainer.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions