4

I have created a task in VS Code in order to run my python scripts "on the push of a button", but now I want to experiment with sockets, so I want to run a server and a client at the same time. Server starts without any problem, but when I try to fire up the client, VS Code tells me that "The task 'Python (servcmd)' is already active.". Here is the task I created:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Python",
            "type": "shell",
            "command": "python",
            "args": [
                "${file}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

So how do I run multiple instances of the same task at once? Or if this isn't possible, how can I run multiple python scripts at the same time in VS Code without having to write any command line? Thanks!

1 Answer 1

1

It appears that vscode does not consider the args prop when checking if a task has already been started, ie. it thinks the server and client tasks are the same task.

To fix it, I found a small trick: just add a space to the end of the second task's command string. Now, since "python" != "python ", it recognizes the tasks as different so lets you start both.

(In my project, I used this trick for the "script" field of a {type: "npm", ...} task, but I'm assuming the trick works for regular {type: "shell", ...} tasks as well.)

1
  • Thank you very much sir this trick worked flawlessly! :) Commented Nov 20, 2020 at 4:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .