Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiprocessing triggers preLaunchTask and postDebugTask more than once #99

Closed
omartin2010 opened this issue Apr 3, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@omartin2010
Copy link

Environment data

  • DEBUGPY version: 1.0.0b4
  • OS and version: ubuntu18.04
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.9
  • Using VS Code or Visual Studio:VS Code

Actual behavior

When I launch a simple program that involves multiprocessing, upon firing of another process, the preLaunchTask runs more than one time (once per process as I understand). Same goes for the postDebugTask, which seems to run more than one time.

Expected behavior

The preLaunchTask should run once only, as well as the postDebugTask.

Steps to reproduce:

  1. Get this in launch.json :
        {
            "name": "Python: mp.py",
            "type": "python",
            "request": "launch",
            "preLaunchTask": "testStartTask",
            "program": "${workspaceFolder}/testing_code/mp.py",
            "console": "integratedTerminal",
            "debugAdapterPath": "/home/omartin/proj/debugpy/src/debugpy/adapter",
            "postDebugTask": "testStopTask"
        }
  1. Get this in tasks.json:
        {
            "label": "testStartTask",
            "type": "shell",
            "isBackground": false,
            "command":[
                "echo helloStart `date`"
            ],
            "options": {
                "shell": {
                    "executable": "/bin/bash",
                    "args": [
                        "-c"
                    ]
                }
            },
            "problemMatcher": [
                "$eslint-compact"
            ]
        },
        {
            "label": "testStopTask",
            "type": "shell",
            "isBackground": false,
            "command":[
                "echo helloStop `date`"
            ],
            "options": {
                "shell": {
                    "executable": "/bin/bash",
                    "args": [
                        "-c"
                    ]
                }
            },
            "problemMatcher": [
                "$eslint-compact"
            ]
        },
  1. mp.py looks like this
from multiprocessing import Pool
import traceback


def f(x):
    return x * x


if __name__ == '__main__':
    # start 4 worker processes
    try:
        with Pool(processes=4) as pool:

            # print "[0, 1, 4,..., 81]"
            print(pool.map(f, range(10)))
            print("For the moment, the pool remains available for more work")

    except:
        print(traceback.print_exc())
    # exiting the 'with'-block has stopped the pool
    print("Now the pool is closed and no longer available")

I also needed the fix for connection refused error that I have in my version of debug.py.

It seems, by the output of this, that when my process forks, it runs the preLaunchTask a 2nd time, but for each process that terminates (4 in this example), it runs the postDebugTask.

@omartin2010
Copy link
Author

@int19h as discussed, I think you've got all that's needed to repro easily.

@omartin2010 omartin2010 changed the title multiprocessing will result in running preLaunchTask and postDebugTasks more than once multiprocessing triggers preLaunchTask and postDebugTasks more than once Apr 3, 2020
@omartin2010 omartin2010 changed the title multiprocessing triggers preLaunchTask and postDebugTasks more than once multiprocessing triggers preLaunchTask and postDebugTask more than once Apr 3, 2020
@int19h int19h self-assigned this Apr 3, 2020
@int19h int19h added the bug Something isn't working label Apr 3, 2020
int19h added a commit to int19h/debugpy that referenced this issue Apr 3, 2020
…gTask more than once

Remove "preLaunchTask" and "postDebugTask" from derived debug configurations generated for subprocesses.
@int19h int19h closed this as completed in 47dd3da Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants