DamnWidget / anaconda

Anaconda turns your Sublime Text 3 in a full featured Python development IDE including autocompletion, code linting, IDE features, autopep8 formating, McCabe complexity checker Vagrant and Docker support for Sublime Text 3 using Jedi, PyFlakes, pep8, MyPy, PyLint, pep257 and McCabe that will never freeze your Sublime Text 3
http://damnwidget.github.io/anaconda/
GNU General Public License v3.0
2.21k stars 260 forks source link

Anaconda stops working after a while #735

Open sleighsoft opened 6 years ago

sleighsoft commented 6 years ago

Expected Behaviour

Auto completion and show documentation work

Actual Behaviour

Auto completion and all other anaconda feature work and stop working after a couple of minutes.

Steps to Reproduce

I don't know. It might be related to "Project switch detected" even though I just have a single project opened.

ST3, Anaconda and OS versions

Win 10 ST3 Build 3143 Anaconda version from today

ST3 Console Logs

DPI scale: 1
startup, version: 3143 windows x64 channel: stable
executable: /C/Progams/Sublime/sublime_text.exe
working dir: /C/Progams/Sublime
packages path: /C/Users/AppData/Roaming/Sublime Text 3/Packages
state path: /C/Users/AppData/Roaming/Sublime Text 3/Local
zip path: /C/Progams/Sublime/Packages
zip path: /C/Users/AppData/Roaming/Sublime Text 3/Installed Packages
ignored_packages: ["Python", "Vintage"]
pre session restore time: 0.113682
startup time: 0.175682
first paint time: 0.179682
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin 0_package_control_loader.00-package_control
reloading plugin MagicPython.sublime
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin SideBarEnhancements.SideBar
reloading plugin SideBarEnhancements.SideBarAPI
reloading plugin SideBarEnhancements.SideBarDefaultDisable
reloading plugin Anaconda.anaconda
reloading plugin Anaconda.setup
reloading plugin Anaconda.version
plugins loaded
Package Control: No updated packages
anacondaST3: Project or interpreter switch detected...
anacondaST3: Project or interpreter switch detected...
anacondaST3: Project or interpreter switch detected...
anacondaST3: Project or interpreter switch detected...
anacondaST3: Project or interpreter switch detected...
anacondaST3: Project or interpreter switch detected...
anacondaST3: Project or interpreter switch detected...
anacondaST3: Project or interpreter switch detected...
anacondaST3: Project or interpreter switch detected...

Anaconda's JsonServer Logs

2017-12-20 21:47:57,257: INFO    : Anaconda Server started in 58195 for PID 228 with cache dir C:\Users\Julian\AppData\Roaming\Jedi\Jedi\mp2017 and extra paths C:\Development\miniconda\envs\mpgan\lib\site-packages,C:\Development\miniconda\envs\mpgan\Lib\site-packages\tensorflow\contrib,C:\Development\Github\mp2017-gan
2017-12-20 21:47:57,317: INFO    : Incomming connection from ('127.0.0.1', 58198)
2017-12-20 21:47:57,318: INFO    : Incomming connection from ('127.0.0.1', 58199)
2017-12-20 21:47:57,321: INFO    : client requests: lint
2017-12-20 21:47:57,715: INFO    : client requests: lint
2017-12-20 21:48:01,865: INFO    : client requests: lint
DamnWidget commented 6 years ago

When you get the Project or interpreter switch detected is because the python_interpreter in your configuration (per project, per user or global) is not the same than the one that is currently being used by the anaconda's JsonServer so anaconda kills that JsonServer and starts a new one with the new interpreter.

To be able to see which interpreters are in play in your system for a given view (buffer) at any time just open the Sublime Text 3 console and write:

from Anaconda.anaconda_lib.helpers import get_settings
from Anaconda.anaconda_lib.workers.market import Market

print('Configured Interpreter: {}'.format(get_settings(view, 'python_interpreter')))
print('In use Interpreter for view {}: {}'.format(view.file_name(), Market.get(Market, window.id()).interpreter.raw_interpreter))
sleighsoft commented 6 years ago

This is a working setting

>>> from Anaconda.anaconda_lib.helpers import get_settings
>>> from Anaconda.anaconda_lib.workers.market import Market
>>> print('Configured Interpreter: {}'.format(get_settings(view, 'python_interpreter')))
Configured Interpreter: C:\Development\miniconda\envs\test\python.exe
>>> print('In use Interpreter for view {}: {}'.format(view.file_name(), Market.get(Market, window.id()).interpreter.raw_interpreter))
In use Interpreter for view C:\Development\Github\mp2017-gan\...\pipelines.py: C:\Development\miniconda\envs\test\python.exe
>>> from Anaconda.anaconda_lib.helpers import get_settings
>>> from Anaconda.anaconda_lib.workers.market import Market
>>> print('Configured Interpreter: {}'.format(get_settings(view, 'python_interpreter')))
Configured Interpreter: C:\Development\miniconda\envs\test\python.exe
>>> print('In use Interpreter for view {}: {}'.format(view.file_name(), Market.get(Market, window.id()).interpreter.raw_interpreter))
In use Interpreter for view C:\Development\Github\..\pipelines.py: python

This is what I get once I run into the interpreter switch problem. After that anaconda does not work anymore.

DamnWidget commented 6 years ago

The .raw_interpreter property of the Worker.interpreter object is set on initialization only and it gets initialized if there is a change in the python_interpreter configuration option, as it only gets set after reading python_interpreter and with the value of the python_interpreter, this is probably some corner case with windows (and probably the anaconda python distribution) as I don't use Windows at all and could not test the plugin on Windows as deep as in other platforms.

To get rid of the annoyance just set the auto_project_switch property in your config to false

detly commented 6 years ago

I had this exact problem because I entered ~/Code/p3-gitlab-svn/bin/python in my project settings. Anaconda would see that as different to /home/heerij/Code/p3-gitlab-svn/bin/python and keep killing and restarting the interpreter. But... it only happened if I used "go to definition" while in a site-packages installed module in a virtualenv.

Basically, I had my own script open, I would do ctrl-alt-g on dulwich.client.send_pack(). This would open and jump to the relevant file. Then when I tried to to ctrl-alt-g on write_pack_contents I'd start seeing the message anacondaST3: Project or interpreter switch detected...

>>> print('Configured Interpreter: {}'.format(get_settings(view, 'python_interpreter')))
Configured Interpreter: /home/heerij/Code/p3-gitlab-svn/bin/python
>>> print('In use Interpreter for view {}: {}'.format(view.file_name(), Market.get(Market, window.id()).interpreter.raw_interpreter))
In use Interpreter for view /home/heerij/Code/p3-gitlab-svn/lib/python3.6/site-packages/dulwich/client.py: ~/Code/p3-gitlab-svn/bin/python

The problem stopped when I used the full path instead of ~/.... It also stopped if the site-packages module source was already open!

This is a bit muddled because I'm just getting the notes down before I need to leave the computer. If I have time later, I'll try to create a test procedure for you.

Off the top of my head, with no knowledge of the source whatsoever, I'd suggest there's a comparison between a path that's been run through os.path.abspath() and a path that has been pulled straight from settings...?

(Ubuntu 17.04, ST3 3143, latest Anaconda in PC)

sleighsoft commented 6 years ago

It could definitely be an issue with go to definition and site packages. These are things I did aswell @DamnWidget I have set auto project switch to false in my project .anaconda file but it does not seem to help.

DamnWidget commented 6 years ago

Do you have any new log?

sleighsoft commented 6 years ago

The anaconda_jsonserver.log does not show any new insights.

ykvch commented 6 years ago

In my case noted multiple anaconda servers keep running when anaconda stops responding to GUI. So to reset it, closing ST3 and manually killing jsonservers is required. Not sure when exactly that happens though (extensively using "quick project switch" and having multiple projects open in separate ST3 windows).

upd.: It seems that issue is caused by using tilde (~) instead of full homedir path in project settings (same as @detly noted).