Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Repeated post tasks aren't correctly ordered

Open
#1,006 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
cli, tooling

Research direction

Start by reproducing the issue with the Python task definitions in the report and inspect Invoke's task execution and pre/post-task ordering logic. Done means the shared post task runs only once, after the last task that declares it, producing the expected output.

Written by the indexing model from the issue text.

Description

Description

When I set a post task on multiple tasks Invoke correctly only executes it once. But it is executed after the first task that has it as a post task, instead of waiting until the last task is done which has the task as post task.

Code

import invoke


@invoke.task
def post_task(_: invoke.Context) -> None:
    print('The last task')


@invoke.task(post=[post_task])
def pre_task_1(_: invoke.Context) -> None:
    print('The first pre task')


@invoke.task(post=[post_task])
def pre_task_2(_: invoke.Context) -> None:
    print('The second pre task')


@invoke.task(default=True, pre=[pre_task_1, pre_task_2], post=[post_task])
def main(ctx: invoke.Context) -> None:
    print('The main task')

Expected output

The first pre task
The second pre task
The main task
The last task

Output result

The first pre task
The last task
The second pre task
The main task

Additional information

  • Invoke 2.2.0
  • Python 3.11.6
Dominant language
Python
Stars
4.8k
Forks
412
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pyinvoke/invoke

All issues in pyinvoke/invoke

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.