Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Concurrent imports cause error in force_pydevd #1888

Closed
int19h opened this issue Oct 31, 2019 · 0 comments
Closed

Concurrent imports cause error in force_pydevd #1888

int19h opened this issue Oct 31, 2019 · 0 comments
Assignees
Labels
Milestone

Comments

@int19h
Copy link
Contributor

int19h commented Oct 31, 2019

Happened in Flask multiproc test on macOS, but I think it can potentially occur in any scenario where a module is imported concurrently from another thread:

I+05.947: Debuggee-86 stderr:
          b'Error on request:\n'
          b'Traceback (most recent call last):\n'
          b'  File "/Users/runner/runners/2.159.2/work/1/s/.tox/py37/lib/python3.7/site-packages/werkzeug/serving.py", line 304, in run_wsgi\n'
          b'    execute(self.server.app)\n'
          b'  File "/Users/runner/runners/2.159.2/work/1/s/.tox/py37/lib/python3.7/site-packages/werkzeug/serving.py", line 292, in execute\n'
          b'    application_iter = app(environ, start_response)\n'
          b'  File "/Users/runner/runners/2.159.2/work/1/s/.tox/py37/lib/python3.7/site-packages/flask/_compat.py", line 36, in reraise\n'
          b'    raise value\n'
          b'  File "/Users/runner/runners/2.159.2/work/1/s/tests/test_data/flask1/__init__.py", line 1, in <module>\n'
          b'    import debug_me  # noqa\n'
          b'  File "/Users/runner/runners/2.159.2/work/1/s/tests/DEBUGGEE_PYTHONPATH/debug_me/__init__.py", line 49, in <module>\n'
          b'    import ptvsd.server\n'
          b'  File "/Users/runner/runners/2.159.2/work/1/s/.tox/py37/lib/python3.7/site-packages/ptvsd/server/__init__.py", line 9, in <module>\n'
          b'    import ptvsd._vendored.force_pydevd  # noqa\n'
          b'  File "/Users/runner/runners/2.159.2/work/1/s/.tox/py37/lib/python3.7/site-packages/ptvsd/_vendored/force_pydevd.py", line 14, in <module>\n'
          b"    prefix_matcher('pydev', '_pydev'))\n"
          b'  File "/Users/runner/runners/2.159.2/work/1/s/.tox/py37/lib/python3.7/site-packages/ptvsd/_vendored/__init__.py", line 101, in check_modules\n'
          b'    for modname, mod in sys.modules.items():\n'
          b'RuntimeError: dictionary changed size during iteration\n'

It needs to take a snapshot of the module list before iterating.

@int19h int19h added the Bug label Oct 31, 2019
@int19h int19h self-assigned this Oct 31, 2019
@int19h int19h added this to the Oct 2019.3 milestone Oct 31, 2019
int19h added a commit to int19h/ptvsd that referenced this issue Oct 31, 2019
Iterate over a snapshot of sys.modules when checking loaded modules.
@int19h int19h closed this as completed in 0e8f1fa Oct 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant