weixin_39575502
2021-01-07 13:34 阅读 110

Python jedi language server takes ~100% CPU while dubugging

This is a copy of the issue at here. They suggested me to raise the issue here and closed that one.

Version: 1.46.1 Commit: cd9ea64 Date: 2020-06-17T21:17:14.222Z Electron: 7.3.1 Chrome: 78.0.3904.130 Node.js: 12.8.1 V8: 7.8.279.23-electron.0 OS: Darwin x64 19.5.0

Steps to Reproduce:

Use default language server "Jedi". Start debugging my project. My project is running as HTTP Server taking POST request, processing request, and sending response back. While debugging, the code can be run line by line smoothly, no hanging or deadlocking, but a python process is running and taking up to ~100% CPU 截屏2020-06-23 上午6 56 19

And this is the ps info of this process: 截屏2020-06-23 上午6 56 46

In most cases, this python process keeps high CPU consumption until I stop debugging, while occasionally it just won't go low unless I exit VSCode.

After I change language server to "Microsoft", this situation hasn't happened so far.

Does this issue occur when all extensions are disabled?: Yes. With Jedi language server, after I disabled all extensions other than Python extension, this issue still occurs.

该提问来源于开源项目:microsoft/vscode-python

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • weixin_39612733 weixin_39612733 2021-01-07 13:34

    Hi , thank you for reaching out!

    We haven't changed anything Jedi-related in the last few releases, does it happen only when debugging? Can you reproduce it when only using built-in Python packages, or does it happen when you use specific packages?

    Ultimately completion.py is going to be deprecated in favour of https://github.com/microsoft/vscode-python/issues/11995, feel free to upvote it to help us prioritize it.

    Thank you!

    点赞 评论 复制链接分享
  • weixin_39575502 weixin_39575502 2021-01-07 13:34

    I cannot reproduce it on every projects. In this particular project, it uses following non built-in packages:

    mysql schema extract_msg lxml matplotlib openpyxl xlrd

    I debug the code by stepping over each line, and step into at some critical functions. What I found odd is that each time I step over one line, the 'python 3.7' process will show up and take up CPU at ~100% for around 3~5 minutes and get back to normal. If I continuously step over a number of lines, that process will accumulate the "show-up" time. That might explain why it could keep hi-CPU usage for a long time because sometimes I could do a very lengthy step-over's or step-into's.

    点赞 评论 复制链接分享
  • weixin_39612733 weixin_39612733 2021-01-07 13:34

    Do you get high CPU usage when you're not debugging as well?

    点赞 评论 复制链接分享
  • weixin_39575502 weixin_39575502 2021-01-07 13:34

    No, or not that I can notice.

    Kim-Adeline Miguel 于2020年6月26日 周五12:03写道:

    Do you get high CPU usage when you're not debugging as well?

    — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-python/issues/12522#issuecomment-650346233, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFJY6537RRTB5MZC3USWWTLRYTWJDANCNFSM4OGB7BPA .

    点赞 评论 复制链接分享
  • weixin_39612733 weixin_39612733 2021-01-07 13:34

    Strange 🤔 In any case, the plan for the extension is to get rid of completion.py in https://github.com/microsoft/vscode-python/issues/11995 (feel free to give it a 👍 if you want to see it implemented sooner than later), so I'm closing in favour of it. In the meantime, using the Microsoft Python Language Server (as you already do) is a workaround.

    点赞 评论 复制链接分享

相关推荐