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

Simple ProcessPoolExecutor example code fails in VSCode-Python #4684

Closed
ericdrobinson opened this issue Mar 8, 2019 · 2 comments
Closed
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug

Comments

@ericdrobinson
Copy link

The following simple script was adapted from the "Executing code in thread or process pools" documentation for Python 3.7. The adaptations allow the code to be run in Python 3.6.

import asyncio
import concurrent.futures
import os

def cpu_bound():
    print(os.getpid())
    return sum(i * i for i in range(10 ** 7))

async def main():
    print(os.getpid())
    loop = asyncio.get_event_loop()

    # Run in a custom process pool:
    with concurrent.futures.ProcessPoolExecutor() as pool:
        result = await loop.run_in_executor(
            pool, cpu_bound)
        print('custom process pool', result)

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
    loop.close()
    print('done')

Running the code above with the Python: Current File (Integrated Terminal) debugger profile appears to result in a deadlock (no pid is printed from the cpu_bound function). Running that very same code directly with Python 3.6 via the command line works as expected. If the ProcessPoolExecutor is replaced with ThreadPoolExecutor the code appears to run fine using the debugger.

Environment data

  • VS Code version: 1.32.1
  • Extension version: 2019.2.5558
  • OS and version: macOS 10.14.3
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda 3.6.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: NA

Expected behaviour

The script runs to completion and prints two pid numbers and the result of the computation:

10385
10386
custom process pool 333333283333335000000
done

Actual behaviour

The script prints the first pid and then pauses until the user manually stops the debugger. Output:

10412

Steps to reproduce:

  1. Setup a basic Python 3.6 environment in VSCode.
  2. Create an __init__.py file and add the above script to it.
  3. Use the vscode-python extension to attempt to debug the __init__.py file with the "Python: Current File (Integrated Terminal)" launch profile.

Logs

Output for Python in the Output panel: None.

Output from Console under the Developer Tools panel: None. (Not strictly true. There is an "[Extension Host] undefined session received in acceptDebugSessionStarted" error but it seems unrelated as it appears regardless of the contents of the file being debugged.)

@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Mar 8, 2019
@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug area-debugging upstream-ptvsd labels Mar 11, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Mar 11, 2019
@gramster
Copy link
Member

gramster commented Sep 3, 2019

Fixed in March on debugger side.

@gramster gramster closed this as completed Sep 3, 2019
@ghost ghost removed the needs upstream fix label Sep 3, 2019
@ericdrobinson
Copy link
Author

ericdrobinson commented Sep 3, 2019

@gramster Can you please point to the PR that fixes this? Following @DonJayamanne's [breadcrumbs] [lead to] [this still-open-issue] on the debugger side, so far as I can tell...

@lock lock bot locked as resolved and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants