pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

file analysis hanging infinitly, and subsequently pylance does not work correctly any more

Open roebel opened this issue 1 year ago • 17 comments

Environment data

  • Language Server version: v2024.3.2
  • OS and version: macos sonoma 14.1
  • Python version (& distribution if applicable, e.g. Anaconda): conda-forge python 3.10.13

Code Snippet

Not available

Expected behavior

Code analysis should end in a finite time

Actual behavior

I randomly encounter the problem that code analysis does not finish and keeps turning with the notification

"X file(s) to analyze" X being an integer between 1 to 8

If this happens certain functions of code annotation are unavailable. I searched unsuccessfully to stop the analysis but did not find any, besides using the "close folder" menu of the vs code editor and reopening the project from open recent. After reopening code analysis may either restart analysis and finish normally, or directly enter the state with no analysis running.

The given state of the "analysis hanging" situation appears very often, but after a random amount of using the editor, which could be between 15 minutes to a few hours. When code analysis is hanging the tracing log does not produce any output. I generally have multiple vs code windows open working on different projects in parallel and my feeling is that the problem is happening less likely if I have only one window open.

Logs

I enabled tracing in the situation with code analysis hanging and there are no messages printed. Given the variable time (>15min) until the problem appears I don't see how I could produce a reasonable tracing log.

roebel avatar Mar 30 '24 09:03 roebel

I forgot to mention that I have had the same problem since I started using vs code (one year ago), initially using Ubuntu 22.4. At that time I thought it would be a particular issue on Linux, but now that I have been working on MacOS (for 5 months), the same issue appeared.

roebel avatar Mar 30 '24 09:03 roebel

I have the same problem this week. I found my ipynb file was not running well and the VS code became very slow. It seems to check and reload the kernel whenever I click the run button of the cell. Because the cell does not spend too much time. Even though execute the basic 1+1 calculation. It keeps turning" go to" icon or when you don't do anything with the notification "X file(s) to analyze" X being also an integer between 5-50. The info of my VS: image

Version: 1.87.2 (user setup) Date: 2024-03-08T15:20:17.278Z Electron: 27.3.2 ElectronBuildId: 26836302 Chromium: 118.0.5993.159 Node.js: 18.17.1 V8: 11.8.172.18-electron.0 OS: Windows_NT x64 10.0.22631 Kernel of Python version (& distribution if applicable, e.g. Anaconda): conda-forge python 3.8.18

Renzhebing avatar Apr 02 '24 01:04 Renzhebing

@Renzhebing your issue looks related to execution of cells, not pylance being unable to provide analysis. In our situation you can't get completions or hover text while Pylance is busy. Execution isn't impacted by Pylance though.

rchiodo avatar Apr 02 '24 18:04 rchiodo

let us provide a command that start trace logging without changing settings so user can capture things right away.

heejaechang avatar Apr 03 '24 18:04 heejaechang

created this issue - https://github.com/microsoft/pylance-release/issues/5724

heejaechang avatar Apr 03 '24 18:04 heejaechang

I just had the problem after an update of vscode and this time vscode displayed a message saying pylance crashed, and there was a hint indicating that I may want to use a local Node.js due to memory limitations to < 4GB for the Node.js that is built into vscode. While I found it hard to believe that my source code would generate 4GB of memory usage in pylance I nevertheless tried running a local node executable and it appears the problem is now solved. I'll let it run still a bit further but if the problem does not turn up again I will close the issue.

roebel avatar Apr 08 '24 20:04 roebel

Turns out that was not the problem. It was indeed as well the first time I had the notification about Pylance crashing. Now after running this for the last two or three days, I again have a state with "4 files to analyze" state hanging forever. I had it not happening for at least a day, that's when I send the previous message. But I was also less bold in running multiple vscode editors at the same time. Now assuming the problem was fixed I started again alternatingly working with 2-3 projects at the same time, and the problem reappeared. Could it be that the different Pylance instances clash somewhere?

roebel avatar Apr 10 '24 11:04 roebel

Facing the same issue, after some times, Pylance seems to get stuck in analyzing file, and nothing runs anymore. The "X files to analyze" pops up and disappear, but even when it's not there, nothing works (no completion, no typing, etc.).

After enabling TRACE output for analyzing, it looks Pylance is trying to analyze the notebook cell again and again, even if no changes occurred. There are tons of "analyzing: XXX" logs (pointing to the notebook) even when I do nothing.

Holt59 avatar Apr 17 '24 12:04 Holt59

Can you share a notebook and python package installs?

bschnurr avatar Apr 17 '24 14:04 bschnurr

Can you share a notebook and python package installs?

I cannot share the notebook or the python package installs because it contains sensitive information. What I can tell is that it appears (at least more often) with notebooks that contains widgets from either tqdm or bokeh (on multiple cells).

Holt59 avatar Apr 17 '24 15:04 Holt59

How about providing some logs.. see https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue

or any kind of similar notebook repo

bschnurr avatar Apr 17 '24 15:04 bschnurr

How about providing some logs.. see https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue

or any kind of similar notebook repo

I'll update logs once I reproduce the problem, but since logs are not anonymized, it's pretty tedious to do so.

As I said above, the log output is basically filled analyzing messages (even when I do nothing on my side)

2024-04-17 18:05:40.498 [info] (21728) [BG(1)] analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#pylancePrefixCell ...
2024-04-17 18:05:40.498 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W3sZmlsZQ%3D%3D ...
2024-04-17 18:05:40.498 [info] (21728) [BG(1)]     binding: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W2sZmlsZQ%3D%3D (0ms)
2024-04-17 18:05:40.498 [info] (21728) [BG(1)]     binding: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W6sZmlsZQ%3D%3D (1ms)
2024-04-17 18:05:40.498 [info] (21728) [BG(1)]     binding: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W3sZmlsZQ%3D%3D (0ms)
2024-04-17 18:05:40.634 [info] (21728) [BG(1)]     checking: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W3sZmlsZQ%3D%3D (136ms)
2024-04-17 18:05:40.635 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W3sZmlsZQ%3D%3D (137ms)
2024-04-17 18:05:40.635 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W6sZmlsZQ%3D%3D ...
2024-04-17 18:05:40.635 [info] (21728) [BG(1)]     checking: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W6sZmlsZQ%3D%3D (0ms)
2024-04-17 18:05:40.635 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W6sZmlsZQ%3D%3D (0ms)
2024-04-17 18:05:40.635 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W2sZmlsZQ%3D%3D ...
2024-04-17 18:05:40.635 [info] (21728) [BG(1)]     checking: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W2sZmlsZQ%3D%3D (0ms)
2024-04-17 18:05:40.635 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W2sZmlsZQ%3D%3D (0ms)
2024-04-17 18:05:40.635 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W1sZmlsZQ%3D%3D ...
2024-04-17 18:05:40.636 [info] (21728) [BG(1)]     checking: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W1sZmlsZQ%3D%3D (0ms)
2024-04-17 18:05:40.636 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W1sZmlsZQ%3D%3D (1ms)
2024-04-17 18:05:40.637 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W5sZmlsZQ%3D%3D ...
2024-04-17 18:05:40.637 [info] (21728) [BG(1)]     checking: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W5sZmlsZQ%3D%3D (1ms)
2024-04-17 18:05:40.637 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W5sZmlsZQ%3D%3D (1ms)
2024-04-17 18:05:40.638 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W0sZmlsZQ%3D%3D ...
2024-04-17 18:05:40.638 [info] (21728) [BG(1)]     checking: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W0sZmlsZQ%3D%3D (0ms)
2024-04-17 18:05:40.638 [info] (21728) [BG(1)]   analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#W0sZmlsZQ%3D%3D (0ms)
2024-04-17 18:05:40.640 [info] (21728) [BG(1)]   checking: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#pylancePrefixCell (3ms)

Holt59 avatar Apr 17 '24 16:04 Holt59

the beginning would be more helps.. "Starting pylance"... etc with all the search paths and environment variables. or any special settings or paths your have

bschnurr avatar Apr 17 '24 16:04 bschnurr

the beginning would be more helps.. "Starting pylance"... etc with all the search paths and environment variables. or any special settings or paths your have

This what I get when I start VS Code:

2024-04-24 14:32:34.480 [info] (Client) Pylance async client (2024.4.1) started with python extension (2024.4.1)
2024-04-24 14:32:36.875 [info] [Info  - 2:32:36 PM] (12012) Pylance language server 2024.4.1 (pyright version 1.1.356, commit 6652c4a8) starting
2024-04-24 14:32:37.244 [info] [Info  - 2:32:37 PM] (12012) Server root directory: file:///c%3A/Users/UUU/.vscode/extensions/ms-python.vscode-pylance-2024.4.1/dist
2024-04-24 14:32:37.432 [info] [Info  - 2:32:37 PM] (12012) Starting service instance "XXX"
2024-04-24 14:32:37.702 [info] [Info  - 2:32:37 PM] (12012) Starting service instance "YYY"
2024-04-24 14:32:38.006 [info] [Info  - 2:32:38 PM] (12012) Starting service instance "ZZZ"
2024-04-24 14:32:38.360 [info] [Info  - 2:32:38 PM] (12012) Background analysis(1) root directory: file:///c%3A/Users/UUU/.vscode/extensions/ms-python.vscode-pylance-2024.4.1/dist
2024-04-24 14:32:38.600 [info] [Info  - 2:32:38 PM] (12012) Background analysis(1) started
2024-04-24 14:32:38.622 [info] [Info  - 2:32:38 PM] (12012) Background analysis(2) root directory: file:///c%3A/Users/UUU/.vscode/extensions/ms-python.vscode-pylance-2024.4.1/dist
2024-04-24 14:32:38.662 [info] [Info  - 2:32:38 PM] (12012) Background analysis(2) started
2024-04-24 14:32:38.663 [info] [Info  - 2:32:38 PM] (12012) Background analysis(3) root directory: file:///c%3A/Users/UUU/.vscode/extensions/ms-python.vscode-pylance-2024.4.1/dist
2024-04-24 14:32:38.665 [info] [Info  - 2:32:38 PM] (12012) Background analysis(3) started
2024-04-24 14:32:38.974 [info] [Info  - 2:32:38 PM] (12012) Setting pythonPath for service "XXX": "C:\Users\UUU\.envs\XXX\Scripts\python.exe"
2024-04-24 14:32:38.976 [info] [Info  - 2:32:38 PM] (12012) Setting environmentName for service "XXX": "3.10.5 (XXX venv)"
2024-04-24 14:32:38.977 [info] [Info  - 2:32:38 PM] (12012) Loading pyproject.toml file at c:\Users\UUU\Code\XXX\pyproject.toml
2024-04-24 14:32:39.895 [info] [Info  - 2:32:39 PM] (12012) Assuming Python version 3.10.5.final.0
2024-04-24 14:32:42.409 [info] [Info  - 2:32:42 PM] (12012) Found 34 source files
2024-04-24 14:32:42.410 [info] [Info  - 2:32:42 PM] (12012) Setting pythonPath for service "YYY": "C:\Users\UUU\.envs\XXX\Scripts\python.exe"
2024-04-24 14:32:42.410 [info] [Info  - 2:32:42 PM] (12012) Setting environmentName for service "YYY": "3.10.5 (XXX venv)"
2024-04-24 14:32:42.907 [info] [Info  - 2:32:42 PM] (12012) Assuming Python version 3.10.5.final.0
2024-04-24 14:32:44.544 [info] [Info  - 2:32:44 PM] (12012) Auto-excluding c:\Users\UUU\Code\rt-cnes\YYY\.tox\py39-lint
2024-04-24 14:32:46.992 [info] [Info  - 2:32:46 PM] (12012) Found 28 source files
2024-04-24 14:32:47.002 [info] [Info  - 2:32:47 PM] (12012) Setting pythonPath for service "ZZZ": "C:\Users\UUU\.envs\XXX\Scripts\python.exe"
2024-04-24 14:32:47.002 [info] [Info  - 2:32:47 PM] (12012) Setting environmentName for service "ZZZ": "3.10.5 (XXX venv)"
2024-04-24 14:32:47.002 [info] [Info  - 2:32:47 PM] (12012) Loading pyproject.toml file at c:\Users\UUU\Code\tools\ZZZ\pyproject.toml
2024-04-24 14:32:47.190 [info] [Info  - 2:32:47 PM] (12012) Assuming Python version 3.10.5.final.0
2024-04-24 14:32:47.625 [info] [Info  - 2:32:47 PM] (12012) Found 17 source files
2024-04-24 14:32:48.616 [info] [Info  - 2:32:48 PM] (12012) Indexer background runner(4) root directory: file:///c%3A/Users/UUU/.vscode/extensions/ms-python.vscode-pylance-2024.4.1/dist (index)
2024-04-24 14:32:48.617 [info] [Info  - 2:32:48 PM] (12012) Indexing(4) started
2024-04-24 14:32:50.691 [info] [Info  - 2:32:50 PM] (12012) [IDX(4)] Long operation: scan packages file:///c%3A/Users/UUU/Code/XXX (2063ms)
2024-04-24 14:32:50.691 [info] [Info  - 2:32:50 PM] (12012) scanned(4) 217 files over 1 exec env
2024-04-24 14:32:53.960 [info] [Info  - 2:32:53 PM] (12012) indexed(4) 157 files over 1 exec env
2024-04-24 14:32:54.157 [info] [Info  - 2:32:54 PM] (12012) Indexing finished(4).

Holt59 avatar Apr 24 '24 12:04 Holt59

might be a dup of this - https://github.com/microsoft/pylance-release/issues/5798

heejaechang avatar Apr 24 '24 22:04 heejaechang

that said, without repro steps, or logs, it would be very hard for us to pin point why it is happening.

heejaechang avatar Apr 24 '24 22:04 heejaechang

that said, without repro steps, or logs, it would be very hard for us to pin point why it is happening.

@heejaechang

I cannot provide full repro steps, as this is kind of randoms, but it happens with about any kind of notebook. At first I thought it was related to bokeh, etc., but apparently not.

The problem is occurring right now for me, I cannot provide the full steps that lead to the problem (except saying "I ran some notebook"), but basically

  • the language server seems to be dead or extremely slow, I open a notebook and autocompletion, linting, etc., are dead or takes forever
  • I can still execute notebook cells, although starting the execution takes more time than usual
  • there is not logs, my only log from "Python Language Server" this morning is (the previous logs are from yesterday, and the notebook in question is not the one I'm trying to run)
2024-04-26 08:55:33.077 [info] [Info  - 8:55:33 AM] (6456) [BG(1)] Long operation: analyzing: file:///c%3A/Users/XXX/Code/YYY/UUU.ipynb.py#pylancePrefixCell (3494ms)
  • after executing a cell, I get the "11 files to analyze" info in the status bar for quite a long time, but with no logs.

If there is a way for me to get extra logs/information when the problem occurs, let me know so that I can give you more details.

Holt59 avatar Apr 26 '24 07:04 Holt59

I believe this is now fixed and it was UI issue not actual infinite execution issue.

https://github.com/microsoft/pyrx/pull/5300

heejaechang avatar Jun 20 '24 17:06 heejaechang