-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Temporary directories are not removed on VS Code exit #4142
Comments
…etermining whether the file system is case sensitive. This addresses #4142.
This will be addressed in the next release. |
Thanks for the quick fix! Out of curiosity I looked at the resolve commit, and I noticed what seems like a bug to me. I could be totally wrong since I don't know the code base at all. The temporary directory which was just created is immediately removed: pyright/packages/pyright-internal/src/common/pathUtils.ts Lines 973 to 980 in c5d1cfc
But at the same time, pyright/packages/pyright-internal/src/common/realFileSystem.ts Lines 332 to 338 in 95c059f
Doesn't that mean that the next caller of |
Ah, that's a good point. I didn't realize that pyright's own This is the only place we use I found a much better solution. |
I think there is another place, this code seems to create empty files, but I also have these orphaned files on my system:
They seem to be auto-generated typing stubs. # Python: 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)]
# Library: builtins, version: unspecified
# Module: builtins, version: unspecified
"Built-in functions, exceptions, and other objects.\n\nNoteworthy: ..."
import typing
class ellipsis(object):
def __getattribute__(self, name) -> typing.Any:
'Return getattr(self, name).'
...
def __init__(self, *args, **kwargs) -> None:
... |
This is included in pyright 1.1.279, which I just published. It will also be included in a future version of pylance. |
@erictraut Today my Pylance updated to version
|
I confirmed that the temp directory created in pyright's main process is correctly cleaned up. However, the temp directory created in the background (worker) process is not. I didn't notice this previously because the debug version of pyright disables the background (worker) process to aid in debugging. My working theory is that this is a bug in node's handling of |
My guess is that the worker threads just die, they don't get a chance to run any cleanup. We might have to post a message to the main thread in order to generate tmp folders/files. Looks like tmp could fix this if it knew it was in a worker by listening to worker.exit and not just process.exit This code here in tmp: That code will only run on the main thread. |
I bet you could do something like this in tmp.js if (isMainThread) {
process.on(EXIT, _garbageCollector)
} else {
worker.on(EXIT, _garbageCollector)
} |
This is addressed in pyright 1.1.281, which I just published. It will also be included in a future release of pylance. |
Hello, |
@noootch, which version of pyright are you using? |
I'm not using it directly but through Pylance 2024.12.1. They use Pyright 1.1.389. |
Thanks, I'm able to repro as well. Looks like something regressed here. Reopening issue. |
let me take a look. |
the issue was the library we use for temp folder. the auto deletion only works for the main process. any new temp folder created by worker or forked process; auto deletion didn't work. fixed by making main process own the temp folder and all other one to use temp folder created by the main process. |
@heejaechang, it apparently regressed. I'm seeing thousands of temp folders remaining on my machine. I guess some of these could be because I'm killing the pyright process when debugging issues, but I don't think that explains all of them. I'll need to investigate and confirm, but I think there's something broken here. |
@heejaechang, when you say "fixed by making main process", do you mean that you previously introduced a fix? Or you are working on a new fix that you haven't checked in yet? I think your analysis and conclusion is correct — that this is caused by temp folders created by the worker or forked process. The temp folders created by the main process do appear to get cleaned up correctly unless pyright crashes or is abnormally terminated (e.g. by an attached debugger). |
yes, I just pushed fix to pyright, can you try again and check whether it is fixed? basically there are 2 fixes.
|
sorry, missed this message. I just pushed the fix. I had to make fix in pylance and push since pylance had the same issue and I had to fix all together. |
I checked out your fix and confirmed that it's working correctly on my machine. Thanks! |
Describe the bug
Pyright doesn't clean up the temporary directories it creates.
To Reproduce
Edit Python code in VS Code while using the Pylance extension, notice how Pyright creates temporary directories which are not removed on VS Code exit.
I have discovered a thousand (almost all empty) Pyright directories in my
TEMP
:Expected behavior
Pyright removes temporary directories on VS Code exit.
VS Code extension or command-line
VS Code with Pylance v2022.11.10
Additional context
Temporary directories are created here, but don't seem to be removed anywhere:
pyright/packages/pyright-internal/src/common/realFileSystem.ts
Lines 332 to 338 in 95c059f
The text was updated successfully, but these errors were encountered: