Closed husanjun closed 3 years ago
Since this will only help when stopping the server on the main thread, and we don't really want to do that, I'm thinking we could try something else.
Instead of deleting the server files, we could try to put a marker file in the server (added such functionality in a recent PR). Then only on starting the server again we would update the server files.
I'm not sure if that would still guarantee a full server stop before we touch the files but could be worth a try.
Yes, you only need to remove the plugin when you remove it, otherwise you just need to update it
We can't distinguish those case though. In both situations we just get plugin_unloaded
called.
https://packagecontrol.io/docs/events
I don't know if it works but I didn't try
Interesting. Didn't remember about it.
@rchl My tests work fine f2644ff
Also I'm assuming that you had server active at the time. Also, which server are you testing with?
Yes,Occurs only in an active state,I use LSP-pyright
This bug plagued windows users for a long time unfortunately. Maybe this diff can help in the short run. In the long run I'm hoping to fix this by running all the necessary async clean up code in the UI thread using a registered exit_handler async function: https://github.com/sublimelsp/sublime_asyncio/blob/master/globalstate.py#L147
In the long run I'm hoping to fix this by running all the necessary async clean up code in the UI thread using a registered exit_handler async function: https://github.com/sublimelsp/sublime_asyncio/blob/master/globalstate.py#L147
Wouldn't that potentially result in server getting called from two different threads? Maybe even deadlocks?
No, because the entire loop stops, and then runs that single async function on the main thread. Potentially, other async operations are also handled in-between the suspension points of the exit handler.
I've tried uninstalling LSP-pyright on Windows when testing https://github.com/sublimelsp/LSP-pyright/issues/75 and gotten:
ignored packages updated to: ["LSP-pyright", "Vintage"]
unloading python 3.3 plugin LSP-pyright.commands
reloading settings Packages/LSP-pyright/LSP-pyright.sublime-settings
unloading python 3.3 plugin LSP-pyright.plugin
Traceback (most recent call last):
File "C:\Program Files\Sublime Text\Lib\python33\sublime_plugin.py", line 243, in unload_module
module.plugin_unloaded()
File "C:\Users\IEUser\AppData\Roaming\Sublime Text\Installed Packages\LSP-pyright.sublime-package\plugin.py", line 15, in plugin_unloaded
LspPyrightPlugin.cleanup()
File "C:\Users\IEUser\AppData\Roaming\SUBLIM~1\Packages\LSP_UT~1\st3\lsp_utils\generic_client_handler.py", line 44, in cleanup
shutil.rmtree(cls.package_storage())
File "./python3.3/shutil.py", line 478, in rmtree
File "./python3.3/shutil.py", line 368, in _rmtree_unsafe
File "./python3.3/shutil.py", line 368, in _rmtree_unsafe
File "./python3.3/shutil.py", line 368, in _rmtree_unsafe
File "./python3.3/shutil.py", line 368, in _rmtree_unsafe
File "./python3.3/shutil.py", line 368, in _rmtree_unsafe
File "./python3.3/shutil.py", line 377, in _rmtree_unsafe
File "./python3.3/shutil.py", line 375, in _rmtree_unsafe
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\IEUser\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-pyright\\14.17.1\\language-server\\node_modules\\pyright\\dist'
reloading settings Packages/User/Package Control.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
Package Control: The package LSP-pyright has been removed
reloading settings Packages/User/Package Control.sublime-settings
ignored packages updated to: ["Vintage"]
Error loading C:\Users\IEUser\AppData\Roaming\Sublime Text\Installed Packages\LSP-pyright.sublime-package: [Errno 13] Permission denied: 'C:\\Users\\IEUser\\AppData\\Roaming\\Sublime Text\\Installed Packages\\LSP-pyright.sublime-package'
reloading settings Packages/User/Package Control.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
Which makes sense because nothing is stopping the server on uninstalling the package. Even if it would, there is no guarantee that it will be stopped within one second.
Please see https://github.com/sublimelsp/LSP/pull/1737