Opening python files in vscode will cause the screen to become stiff for a while

Asked 1 years ago, Updated 1 years ago, 129 views

I am writing python code in vscode.Recent updates have affected or are causing the following symptoms:

  • When opened to edit python files (??.py) in vscode, the vscode window itself hardens for more than 10 seconds for a short time and a few minutes for a long time, making it impossible to operate at all

We investigated as follows, but the cause was unknown:

>conda info
conda version: 4.8.3
conda-build version: 3.17.8
python version: 3.7.3.final.0
  • settings.json is empty (python.jediEnabled, python.languageServer is not configured).
  • When installing v2020.1.58038, the above symptoms do not occur (for normal use)
  • The above issues occur when installing a version later than v2020.1.58038 (v2020.2.62710 or later).

In both cases, once vscode operations are available, there is no problem with running, debugging, intellisense, etc.
I couldn't investigate any more with my own knowledge, so I would appreciate it if you could let me know if you know any additional methods or solutions to investigate the cause.Also, please let me know if there is a lack of information.

Thank you for your cooperation.

I got the idea to look it up in procmon, so I looked it up and found out the following:

  • When this problem occurs (extension version is v2020.2.62710 or later), a large number of C drive-wide C:\WINDOWS access (for example, QueryDirectory) appears
  • The above access does not appear when v2020.1.58038 is installed or when extensions are disabled

This suggests that after a certain version, the code may have ended up scanning the C drive to find something.

python windows vscode

2022-09-30 21:48

1 Answers

As for how to manipulate the source of the enhancements, I have found a way to deal with them, so I will introduce them.
The cause of this phenomenon is src/clinet/pythonEnvironments/discovery/locators/sevices/KnownPathService.ts, and if the environment variable PATH contains C:\WINDOWS\System32, use this directory via lookFordInterior>In fact, if you removed the following directory from PATH with the following code:

 diff -- gita/src/client/pythonEnvironments/discovery/locators/services/KnownPathsService.tsb/src/client/pythonEnvironments/discovery/locators/services/KnownPathsService.tsbsb/src/client/pythonEnvironments/discovery/locators/services/KnownPathsService.t. 
index5dd284cc1..3e3a17d19100644
--- a/src/client/pythonEnvironments/discovery/locators/services/KnownPathsService.ts
+++ b/src/client/pythonEnvironments/discovery/locators/services/KnownPathsService.ts
@@ - 95,9+95,14@@export class KnownSearchPathsForInterpreters implementations IKnownSearchPathsForInte
         const platformService=this.serviceContainer.get<IPplatformService> (IPplatformService);
         const pathUtils=this.serviceContainer.get<IPathUtils> (IPathUtils);

+        //ignores C:\\WINDOWS, C:\\WINDOWS\\System32
+        constignoreWinDirFilter=platformService.isWindows
+            ?(p:string): boolean=>!/:\\WINDOWS/i.test(p)
+            :(_:string): boolean=>true;
+
         const searchPaths=currentProcess.env [platformService.pathVariableName]!.split(pathUtils.delimiter)
             .map(p)=>p.trim())
-            .filter((p)=>p.length>0);
+            .filter((p)=>p.length>0&ignoreWinDirFilter(p));

         if(!platformService.isWindows){
             ['/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/sbin'].forEach(p)=>{

(This diff is the difference from the committed c3af16de version.)

However, I felt that these directories were included by default in PATH, so I didn't understand why this only happens in my environment.I don't know what to do anymore, so I personally decided to put this edited local repository in the extensions directory and use it.

If anyone encounters the same problem, I hope it helps.


2022-09-30 21:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.