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

Conversation

@ericsnowcurrently
Copy link
Contributor

This change is intended to accommodate future work (adding more CLI options where using the launch config is insufficient). It also allows us to define a consistent and easy-to-discover CLI, independent of PyDevd.

To be backward compatible, the code also supports the PyDevd CLI (for now).

ptvsd/wrapper.py Outdated
# These are the functions pydevd invokes to get a socket to the client.
pydevd_comm.start_server = start_server
pydevd_comm.start_client = start_client
def install(start_server=start_server, start_client=start_client):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This neuters the assert that we have in pydevd/__init__.py about how pydevd must not be imported before ptvsd - now it can be imported before, but if you don't call install, the detours won't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike the first time I tried this, this function now forces a re-import of the "pydevd" module. Alternately, we could manually replace pydevd.start_server and pydevd.start_client.

Also, where is pydevd/__init__.py?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that was meant to be ptvsd/__init__.py.

What happens if some ptvsd code accidentally imports pydevd before we so the refresh below (e.g. to use some constant from it). Do we end up with two copies of that module hanging around in memory, but no harmful effects otherwise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the code to monkeypatch the start functions rather than re-importing the pydevd module. That fixes issues where pydevd was already imported. I've also added some comments on why we have to jump through these hoops.

@codecov-io
Copy link

codecov-io commented Mar 27, 2018

Codecov Report

Merging #266 into master will decrease coverage by 2.53%.
The diff coverage is 29.53%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #266      +/-   ##
=========================================
- Coverage   59.94%   57.4%   -2.54%     
=========================================
  Files          10      10              
  Lines        1735    1850     +115     
=========================================
+ Hits         1040    1062      +22     
- Misses        695     788      +93
Impacted Files Coverage Δ
ptvsd/__main__.py 25.92% <24.24%> (ø)
ptvsd/__init__.py 87.5% <62.5%> (-7.5%) ⬇️
ptvsd/wrapper.py 50.29% <77.77%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ec1bc9...d0a8b41. Read the comment docs.

@int19h
Copy link
Contributor

int19h commented Mar 27, 2018

Ohh, now I see what's really going on there. Thanks for figuring this out!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants