Skip to content
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

Anaconda causes extreme slowness on remote links with pyvenv #400

Open
mathrick opened this issue Dec 4, 2020 · 5 comments
Open

Anaconda causes extreme slowness on remote links with pyvenv #400

mathrick opened this issue Dec 4, 2020 · 5 comments

Comments

@mathrick
Copy link

mathrick commented Dec 4, 2020

Whenever I try to edit remote files with anaconda-mode and pyvenv, there are constant pauses as, after pretty much every movement, anaconda causes TRAMP to re-open the connection. I haven't been able to pinpoint why exactly it happens, but it seems only to be the case with an active pyvenv-virtual-env, and if I enable debug-on-quit and interrupt one of the connections, anaconda-mode is clearly listed in the backtrace.

I created a gist which reproduces the issue with a minimal setup based on my actual config (please give it a couple seconds to set up the environment). Try moving around the file, defining a function, etc. It assumes an SSH server on localhost to simulate the remote access. Since localhost-based TRAMP access is as fast as it can be, the issue isn't as visible as it is during a real remote session, so injecting some artificial latency helps. On Linux, it can be achieved with:

$ sudo tc qdisc add dev lo root handle 1:0 netem delay 20msec

And removed again with:

$ tc qdisc del dev lo root
@mathrick
Copy link
Author

mathrick commented Dec 4, 2020

Here's a backtrace:

Debugger entered--Lisp error: (quit)
  signal(quit nil)
  tramp-maybe-open-connection((tramp-file-name "ssh" nil nil "localhost" nil "/tmp/anaconda-repro-OSgti/home/python-code/" nil))
  tramp-sh-handle-start-file-process("anaconda-mode" #<buffer *anaconda-mode*> "python3" "-c" "\nfrom __future__ import print_function\n\n# CLI arguments.\n\nimport sys\n\nassert len(sys.argv) > 3, 'CLI arguments: %s' % sys.argv\n\nserver_directory = sys.argv[-3]\nserver_address = sys.argv[-2]\nvirtual_environment = sys.argv[-1]\n\n# Ensure directory.\n\nimport os\n\nserver_directory = os.path.expanduser(server_directory)\nvirtual_environment = os.path.expanduser(virtual_environment)\n\nif not os.path.exists(server_directory):\n    os.makedirs(server_directory)\n\n# Installation check.\n\njedi_dep = ('jedi', '0.13.0')\nservice_factory_dep = ('service_factory', '0.1.5')\n\nmissing_dependencies = []\n\ndef instrument_installation():\n    for package in (jedi_dep, service_factory_dep):\n        package_is_installed = False\n        for path in os.listdir(server_directory):\n            path = os.path.join(server_directory, path)\n            if path.endswith('.egg') and os.path.isdir(path):\n                if path not in sys.path:\n                    sys.path.insert(0, path)\n                if package[0] in path:\n                    package_is_installed = True\n        if not package_is_installed:\n            missing_dependencies.append('>='.join(package))\n\ninstrument_installation()\n\n# Installation.\n\ndef install_deps():\n    import site\n    import setuptools.command.easy_install\n    site.addsitedir(server_directory)\n    cmd = ['--install-dir', server_directory,\n           '--site-dirs', server_directory,\n           '--always-copy','--always-unzip']\n    cmd.extend(missing_dependencies)\n    setuptools.command.easy_install.main(cmd)\n    instrument_installation()\n\nif missing_dependencies:\n    install_deps()\n\ndel missing_dependencies[:]\n\ntry:\n    import jedi\nexcept ImportError:\n    missing_dependencies.append('>='.join(jedi_dep))\n\ntry:\n    import service_factory\nexcept ImportError:\n    missing_dependencies.append('>='.join(service_factory_dep))\n\n# Try one more time in case if anaconda installation gets broken somehow\nif missing_dependencies:\n    install_deps()\n    import jedi\n    import service_factory\n\n# Setup server.\n\nassert jedi.__version__ >= jedi_dep[1], 'Jedi version should be >= %s, current version: %s' % (jedi_dep[1], jedi.__version__,)\n\nif virtual_environment:\n    virtual_environment = jedi.create_environment(virtual_environment, safe=False)\nelse:\n    virtual_environment = None\n\n# Define JSON-RPC application.\n\nimport functools\nimport threading\n\ndef script_method(f):\n    @functools.wraps(f)\n    def wrapper(source, line, column, path):\n        timer = threading.Timer(30.0, sys.exit)\n        timer.start()\n        result = f(jedi.Script(source, line, column, path, environment=virtual_environment))\n        timer.cancel()\n        return result\n    return wrapper\n\ndef process_definitions(f):\n    @functools.wraps(f)\n    def wrapper(script):\n        definitions = f(script)\n        if len(definitions) == 1 and not definitions[0].module_path:\n            return '%s is defined in %s compiled module' % (\n                definitions[0].name, definitions[0].module_name)\n        return [[definition.module_path,\n                 definition.line,\n                 definition.column,\n                 definition.get_line_code().strip()]\n                for definition in definitions\n                if definition.module_path] or None\n    return wrapper\n\n@script_method\ndef complete(script):\n    return [[definition.name, definition.type]\n            for definition in script.completions()]\n\n@script_method\ndef company_complete(script):\n    return [[definition.name,\n             definition.type,\n             definition.docstring(),\n             definition.module_path,\n             definition.line]\n            for definition in script.completions()]\n\n@script_method\ndef show_doc(script):\n    return [[definition.module_name, definition.docstring()]\n            for definition in script.goto_definitions()]\n\n@script_method\n@process_definitions\ndef goto_definitions(script):\n    return script.goto_definitions()\n\n@script_method\n@process_definitions\ndef goto_assignments(script):\n    return script.goto_assignments()\n\n@script_method\n@process_definitions\ndef usages(script):\n    return script.usages()\n\n@script_method\ndef eldoc(script):\n    signatures = script.call_signatures()\n    if len(signatures) == 1:\n        signature = signatures[0]\n        return [signature.name,\n                signature.index,\n                [param.description[6:] for param in signature.params]]\n\n# Run.\n\napp = [complete, company_complete, show_doc, goto_definitions, goto_assignments, usages, eldoc]\n\nservice_factory.service_factory(app, server_address, 0, 'anaconda_mode port {port}')\n" "~/.emacs.d/anaconda-mode/0.1.13" "0.0.0.0" "/ssh:localhost:/tmp/anaconda-repro-OSgti/home/python-code/venv")
  apply(tramp-sh-handle-start-file-process ("anaconda-mode" #<buffer *anaconda-mode*> "python3" "-c" "\nfrom __future__ import print_function\n\n# CLI arguments.\n\nimport sys\n\nassert len(sys.argv) > 3, 'CLI arguments: %s' % sys.argv\n\nserver_directory = sys.argv[-3]\nserver_address = sys.argv[-2]\nvirtual_environment = sys.argv[-1]\n\n# Ensure directory.\n\nimport os\n\nserver_directory = os.path.expanduser(server_directory)\nvirtual_environment = os.path.expanduser(virtual_environment)\n\nif not os.path.exists(server_directory):\n    os.makedirs(server_directory)\n\n# Installation check.\n\njedi_dep = ('jedi', '0.13.0')\nservice_factory_dep = ('service_factory', '0.1.5')\n\nmissing_dependencies = []\n\ndef instrument_installation():\n    for package in (jedi_dep, service_factory_dep):\n        package_is_installed = False\n        for path in os.listdir(server_directory):\n            path = os.path.join(server_directory, path)\n            if path.endswith('.egg') and os.path.isdir(path):\n                if path not in sys.path:\n                    sys.path.insert(0, path)\n                if package[0] in path:\n                    package_is_installed = True\n        if not package_is_installed:\n            missing_dependencies.append('>='.join(package))\n\ninstrument_installation()\n\n# Installation.\n\ndef install_deps():\n    import site\n    import setuptools.command.easy_install\n    site.addsitedir(server_directory)\n    cmd = ['--install-dir', server_directory,\n           '--site-dirs', server_directory,\n           '--always-copy','--always-unzip']\n    cmd.extend(missing_dependencies)\n    setuptools.command.easy_install.main(cmd)\n    instrument_installation()\n\nif missing_dependencies:\n    install_deps()\n\ndel missing_dependencies[:]\n\ntry:\n    import jedi\nexcept ImportError:\n    missing_dependencies.append('>='.join(jedi_dep))\n\ntry:\n    import service_factory\nexcept ImportError:\n    missing_dependencies.append('>='.join(service_factory_dep))\n\n# Try one more time in case if anaconda installation gets broken somehow\nif missing_dependencies:\n    install_deps()\n    import jedi\n    import service_factory\n\n# Setup server.\n\nassert jedi.__version__ >= jedi_dep[1], 'Jedi version should be >= %s, current version: %s' % (jedi_dep[1], jedi.__version__,)\n\nif virtual_environment:\n    virtual_environment = jedi.create_environment(virtual_environment, safe=False)\nelse:\n    virtual_environment = None\n\n# Define JSON-RPC application.\n\nimport functools\nimport threading\n\ndef script_method(f):\n    @functools.wraps(f)\n    def wrapper(source, line, column, path):\n        timer = threading.Timer(30.0, sys.exit)\n        timer.start()\n        result = f(jedi.Script(source, line, column, path, environment=virtual_environment))\n        timer.cancel()\n        return result\n    return wrapper\n\ndef process_definitions(f):\n    @functools.wraps(f)\n    def wrapper(script):\n        definitions = f(script)\n        if len(definitions) == 1 and not definitions[0].module_path:\n            return '%s is defined in %s compiled module' % (\n                definitions[0].name, definitions[0].module_name)\n        return [[definition.module_path,\n                 definition.line,\n                 definition.column,\n                 definition.get_line_code().strip()]\n                for definition in definitions\n                if definition.module_path] or None\n    return wrapper\n\n@script_method\ndef complete(script):\n    return [[definition.name, definition.type]\n            for definition in script.completions()]\n\n@script_method\ndef company_complete(script):\n    return [[definition.name,\n             definition.type,\n             definition.docstring(),\n             definition.module_path,\n             definition.line]\n            for definition in script.completions()]\n\n@script_method\ndef show_doc(script):\n    return [[definition.module_name, definition.docstring()]\n            for definition in script.goto_definitions()]\n\n@script_method\n@process_definitions\ndef goto_definitions(script):\n    return script.goto_definitions()\n\n@script_method\n@process_definitions\ndef goto_assignments(script):\n    return script.goto_assignments()\n\n@script_method\n@process_definitions\ndef usages(script):\n    return script.usages()\n\n@script_method\ndef eldoc(script):\n    signatures = script.call_signatures()\n    if len(signatures) == 1:\n        signature = signatures[0]\n        return [signature.name,\n                signature.index,\n                [param.description[6:] for param in signature.params]]\n\n# Run.\n\napp = [complete, company_complete, show_doc, goto_definitions, goto_assignments, usages, eldoc]\n\nservice_factory.service_factory(app, server_address, 0, 'anaconda_mode port {port}')\n" "~/.emacs.d/anaconda-mode/0.1.13" "0.0.0.0" "/ssh:localhost:/tmp/anaconda-repro-OSgti/home/python-code/venv"))
  tramp-sh-file-name-handler(start-file-process "anaconda-mode" #<buffer *anaconda-mode*> "python3" "-c" "\nfrom __future__ import print_function\n\n# CLI arguments.\n\nimport sys\n\nassert len(sys.argv) > 3, 'CLI arguments: %s' % sys.argv\n\nserver_directory = sys.argv[-3]\nserver_address = sys.argv[-2]\nvirtual_environment = sys.argv[-1]\n\n# Ensure directory.\n\nimport os\n\nserver_directory = os.path.expanduser(server_directory)\nvirtual_environment = os.path.expanduser(virtual_environment)\n\nif not os.path.exists(server_directory):\n    os.makedirs(server_directory)\n\n# Installation check.\n\njedi_dep = ('jedi', '0.13.0')\nservice_factory_dep = ('service_factory', '0.1.5')\n\nmissing_dependencies = []\n\ndef instrument_installation():\n    for package in (jedi_dep, service_factory_dep):\n        package_is_installed = False\n        for path in os.listdir(server_directory):\n            path = os.path.join(server_directory, path)\n            if path.endswith('.egg') and os.path.isdir(path):\n                if path not in sys.path:\n                    sys.path.insert(0, path)\n                if package[0] in path:\n                    package_is_installed = True\n        if not package_is_installed:\n            missing_dependencies.append('>='.join(package))\n\ninstrument_installation()\n\n# Installation.\n\ndef install_deps():\n    import site\n    import setuptools.command.easy_install\n    site.addsitedir(server_directory)\n    cmd = ['--install-dir', server_directory,\n           '--site-dirs', server_directory,\n           '--always-copy','--always-unzip']\n    cmd.extend(missing_dependencies)\n    setuptools.command.easy_install.main(cmd)\n    instrument_installation()\n\nif missing_dependencies:\n    install_deps()\n\ndel missing_dependencies[:]\n\ntry:\n    import jedi\nexcept ImportError:\n    missing_dependencies.append('>='.join(jedi_dep))\n\ntry:\n    import service_factory\nexcept ImportError:\n    missing_dependencies.append('>='.join(service_factory_dep))\n\n# Try one more time in case if anaconda installation gets broken somehow\nif missing_dependencies:\n    install_deps()\n    import jedi\n    import service_factory\n\n# Setup server.\n\nassert jedi.__version__ >= jedi_dep[1], 'Jedi version should be >= %s, current version: %s' % (jedi_dep[1], jedi.__version__,)\n\nif virtual_environment:\n    virtual_environment = jedi.create_environment(virtual_environment, safe=False)\nelse:\n    virtual_environment = None\n\n# Define JSON-RPC application.\n\nimport functools\nimport threading\n\ndef script_method(f):\n    @functools.wraps(f)\n    def wrapper(source, line, column, path):\n        timer = threading.Timer(30.0, sys.exit)\n        timer.start()\n        result = f(jedi.Script(source, line, column, path, environment=virtual_environment))\n        timer.cancel()\n        return result\n    return wrapper\n\ndef process_definitions(f):\n    @functools.wraps(f)\n    def wrapper(script):\n        definitions = f(script)\n        if len(definitions) == 1 and not definitions[0].module_path:\n            return '%s is defined in %s compiled module' % (\n                definitions[0].name, definitions[0].module_name)\n        return [[definition.module_path,\n                 definition.line,\n                 definition.column,\n                 definition.get_line_code().strip()]\n                for definition in definitions\n                if definition.module_path] or None\n    return wrapper\n\n@script_method\ndef complete(script):\n    return [[definition.name, definition.type]\n            for definition in script.completions()]\n\n@script_method\ndef company_complete(script):\n    return [[definition.name,\n             definition.type,\n             definition.docstring(),\n             definition.module_path,\n             definition.line]\n            for definition in script.completions()]\n\n@script_method\ndef show_doc(script):\n    return [[definition.module_name, definition.docstring()]\n            for definition in script.goto_definitions()]\n\n@script_method\n@process_definitions\ndef goto_definitions(script):\n    return script.goto_definitions()\n\n@script_method\n@process_definitions\ndef goto_assignments(script):\n    return script.goto_assignments()\n\n@script_method\n@process_definitions\ndef usages(script):\n    return script.usages()\n\n@script_method\ndef eldoc(script):\n    signatures = script.call_signatures()\n    if len(signatures) == 1:\n        signature = signatures[0]\n        return [signature.name,\n                signature.index,\n                [param.description[6:] for param in signature.params]]\n\n# Run.\n\napp = [complete, company_complete, show_doc, goto_definitions, goto_assignments, usages, eldoc]\n\nservice_factory.service_factory(app, server_address, 0, 'anaconda_mode port {port}')\n" "~/.emacs.d/anaconda-mode/0.1.13" "0.0.0.0" "/ssh:localhost:/tmp/anaconda-repro-OSgti/home/python-code/venv")
  apply(tramp-sh-file-name-handler start-file-process ("anaconda-mode" #<buffer *anaconda-mode*> "python3" "-c" "\nfrom __future__ import print_function\n\n# CLI arguments.\n\nimport sys\n\nassert len(sys.argv) > 3, 'CLI arguments: %s' % sys.argv\n\nserver_directory = sys.argv[-3]\nserver_address = sys.argv[-2]\nvirtual_environment = sys.argv[-1]\n\n# Ensure directory.\n\nimport os\n\nserver_directory = os.path.expanduser(server_directory)\nvirtual_environment = os.path.expanduser(virtual_environment)\n\nif not os.path.exists(server_directory):\n    os.makedirs(server_directory)\n\n# Installation check.\n\njedi_dep = ('jedi', '0.13.0')\nservice_factory_dep = ('service_factory', '0.1.5')\n\nmissing_dependencies = []\n\ndef instrument_installation():\n    for package in (jedi_dep, service_factory_dep):\n        package_is_installed = False\n        for path in os.listdir(server_directory):\n            path = os.path.join(server_directory, path)\n            if path.endswith('.egg') and os.path.isdir(path):\n                if path not in sys.path:\n                    sys.path.insert(0, path)\n                if package[0] in path:\n                    package_is_installed = True\n        if not package_is_installed:\n            missing_dependencies.append('>='.join(package))\n\ninstrument_installation()\n\n# Installation.\n\ndef install_deps():\n    import site\n    import setuptools.command.easy_install\n    site.addsitedir(server_directory)\n    cmd = ['--install-dir', server_directory,\n           '--site-dirs', server_directory,\n           '--always-copy','--always-unzip']\n    cmd.extend(missing_dependencies)\n    setuptools.command.easy_install.main(cmd)\n    instrument_installation()\n\nif missing_dependencies:\n    install_deps()\n\ndel missing_dependencies[:]\n\ntry:\n    import jedi\nexcept ImportError:\n    missing_dependencies.append('>='.join(jedi_dep))\n\ntry:\n    import service_factory\nexcept ImportError:\n    missing_dependencies.append('>='.join(service_factory_dep))\n\n# Try one more time in case if anaconda installation gets broken somehow\nif missing_dependencies:\n    install_deps()\n    import jedi\n    import service_factory\n\n# Setup server.\n\nassert jedi.__version__ >= jedi_dep[1], 'Jedi version should be >= %s, current version: %s' % (jedi_dep[1], jedi.__version__,)\n\nif virtual_environment:\n    virtual_environment = jedi.create_environment(virtual_environment, safe=False)\nelse:\n    virtual_environment = None\n\n# Define JSON-RPC application.\n\nimport functools\nimport threading\n\ndef script_method(f):\n    @functools.wraps(f)\n    def wrapper(source, line, column, path):\n        timer = threading.Timer(30.0, sys.exit)\n        timer.start()\n        result = f(jedi.Script(source, line, column, path, environment=virtual_environment))\n        timer.cancel()\n        return result\n    return wrapper\n\ndef process_definitions(f):\n    @functools.wraps(f)\n    def wrapper(script):\n        definitions = f(script)\n        if len(definitions) == 1 and not definitions[0].module_path:\n            return '%s is defined in %s compiled module' % (\n                definitions[0].name, definitions[0].module_name)\n        return [[definition.module_path,\n                 definition.line,\n                 definition.column,\n                 definition.get_line_code().strip()]\n                for definition in definitions\n                if definition.module_path] or None\n    return wrapper\n\n@script_method\ndef complete(script):\n    return [[definition.name, definition.type]\n            for definition in script.completions()]\n\n@script_method\ndef company_complete(script):\n    return [[definition.name,\n             definition.type,\n             definition.docstring(),\n             definition.module_path,\n             definition.line]\n            for definition in script.completions()]\n\n@script_method\ndef show_doc(script):\n    return [[definition.module_name, definition.docstring()]\n            for definition in script.goto_definitions()]\n\n@script_method\n@process_definitions\ndef goto_definitions(script):\n    return script.goto_definitions()\n\n@script_method\n@process_definitions\ndef goto_assignments(script):\n    return script.goto_assignments()\n\n@script_method\n@process_definitions\ndef usages(script):\n    return script.usages()\n\n@script_method\ndef eldoc(script):\n    signatures = script.call_signatures()\n    if len(signatures) == 1:\n        signature = signatures[0]\n        return [signature.name,\n                signature.index,\n                [param.description[6:] for param in signature.params]]\n\n# Run.\n\napp = [complete, company_complete, show_doc, goto_definitions, goto_assignments, usages, eldoc]\n\nservice_factory.service_factory(app, server_address, 0, 'anaconda_mode port {port}')\n" "~/.emacs.d/anaconda-mode/0.1.13" "0.0.0.0" "/ssh:localhost:/tmp/anaconda-repro-OSgti/home/python-code/venv"))
  tramp-file-name-handler(start-file-process "anaconda-mode" #<buffer *anaconda-mode*> "python3" "-c" "\nfrom __future__ import print_function\n\n# CLI arguments.\n\nimport sys\n\nassert len(sys.argv) > 3, 'CLI arguments: %s' % sys.argv\n\nserver_directory = sys.argv[-3]\nserver_address = sys.argv[-2]\nvirtual_environment = sys.argv[-1]\n\n# Ensure directory.\n\nimport os\n\nserver_directory = os.path.expanduser(server_directory)\nvirtual_environment = os.path.expanduser(virtual_environment)\n\nif not os.path.exists(server_directory):\n    os.makedirs(server_directory)\n\n# Installation check.\n\njedi_dep = ('jedi', '0.13.0')\nservice_factory_dep = ('service_factory', '0.1.5')\n\nmissing_dependencies = []\n\ndef instrument_installation():\n    for package in (jedi_dep, service_factory_dep):\n        package_is_installed = False\n        for path in os.listdir(server_directory):\n            path = os.path.join(server_directory, path)\n            if path.endswith('.egg') and os.path.isdir(path):\n                if path not in sys.path:\n                    sys.path.insert(0, path)\n                if package[0] in path:\n                    package_is_installed = True\n        if not package_is_installed:\n            missing_dependencies.append('>='.join(package))\n\ninstrument_installation()\n\n# Installation.\n\ndef install_deps():\n    import site\n    import setuptools.command.easy_install\n    site.addsitedir(server_directory)\n    cmd = ['--install-dir', server_directory,\n           '--site-dirs', server_directory,\n           '--always-copy','--always-unzip']\n    cmd.extend(missing_dependencies)\n    setuptools.command.easy_install.main(cmd)\n    instrument_installation()\n\nif missing_dependencies:\n    install_deps()\n\ndel missing_dependencies[:]\n\ntry:\n    import jedi\nexcept ImportError:\n    missing_dependencies.append('>='.join(jedi_dep))\n\ntry:\n    import service_factory\nexcept ImportError:\n    missing_dependencies.append('>='.join(service_factory_dep))\n\n# Try one more time in case if anaconda installation gets broken somehow\nif missing_dependencies:\n    install_deps()\n    import jedi\n    import service_factory\n\n# Setup server.\n\nassert jedi.__version__ >= jedi_dep[1], 'Jedi version should be >= %s, current version: %s' % (jedi_dep[1], jedi.__version__,)\n\nif virtual_environment:\n    virtual_environment = jedi.create_environment(virtual_environment, safe=False)\nelse:\n    virtual_environment = None\n\n# Define JSON-RPC application.\n\nimport functools\nimport threading\n\ndef script_method(f):\n    @functools.wraps(f)\n    def wrapper(source, line, column, path):\n        timer = threading.Timer(30.0, sys.exit)\n        timer.start()\n        result = f(jedi.Script(source, line, column, path, environment=virtual_environment))\n        timer.cancel()\n        return result\n    return wrapper\n\ndef process_definitions(f):\n    @functools.wraps(f)\n    def wrapper(script):\n        definitions = f(script)\n        if len(definitions) == 1 and not definitions[0].module_path:\n            return '%s is defined in %s compiled module' % (\n                definitions[0].name, definitions[0].module_name)\n        return [[definition.module_path,\n                 definition.line,\n                 definition.column,\n                 definition.get_line_code().strip()]\n                for definition in definitions\n                if definition.module_path] or None\n    return wrapper\n\n@script_method\ndef complete(script):\n    return [[definition.name, definition.type]\n            for definition in script.completions()]\n\n@script_method\ndef company_complete(script):\n    return [[definition.name,\n             definition.type,\n             definition.docstring(),\n             definition.module_path,\n             definition.line]\n            for definition in script.completions()]\n\n@script_method\ndef show_doc(script):\n    return [[definition.module_name, definition.docstring()]\n            for definition in script.goto_definitions()]\n\n@script_method\n@process_definitions\ndef goto_definitions(script):\n    return script.goto_definitions()\n\n@script_method\n@process_definitions\ndef goto_assignments(script):\n    return script.goto_assignments()\n\n@script_method\n@process_definitions\ndef usages(script):\n    return script.usages()\n\n@script_method\ndef eldoc(script):\n    signatures = script.call_signatures()\n    if len(signatures) == 1:\n        signature = signatures[0]\n        return [signature.name,\n                signature.index,\n                [param.description[6:] for param in signature.params]]\n\n# Run.\n\napp = [complete, company_complete, show_doc, goto_definitions, goto_assignments, usages, eldoc]\n\nservice_factory.service_factory(app, server_address, 0, 'anaconda_mode port {port}')\n" "~/.emacs.d/anaconda-mode/0.1.13" "0.0.0.0" "/ssh:localhost:/tmp/anaconda-repro-OSgti/home/python-code/venv")
  apply(tramp-file-name-handler start-file-process "anaconda-mode" #<buffer *anaconda-mode*> "python3" ("-c" "\nfrom __future__ import print_function\n\n# CLI arguments.\n\nimport sys\n\nassert len(sys.argv) > 3, 'CLI arguments: %s' % sys.argv\n\nserver_directory = sys.argv[-3]\nserver_address = sys.argv[-2]\nvirtual_environment = sys.argv[-1]\n\n# Ensure directory.\n\nimport os\n\nserver_directory = os.path.expanduser(server_directory)\nvirtual_environment = os.path.expanduser(virtual_environment)\n\nif not os.path.exists(server_directory):\n    os.makedirs(server_directory)\n\n# Installation check.\n\njedi_dep = ('jedi', '0.13.0')\nservice_factory_dep = ('service_factory', '0.1.5')\n\nmissing_dependencies = []\n\ndef instrument_installation():\n    for package in (jedi_dep, service_factory_dep):\n        package_is_installed = False\n        for path in os.listdir(server_directory):\n            path = os.path.join(server_directory, path)\n            if path.endswith('.egg') and os.path.isdir(path):\n                if path not in sys.path:\n                    sys.path.insert(0, path)\n                if package[0] in path:\n                    package_is_installed = True\n        if not package_is_installed:\n            missing_dependencies.append('>='.join(package))\n\ninstrument_installation()\n\n# Installation.\n\ndef install_deps():\n    import site\n    import setuptools.command.easy_install\n    site.addsitedir(server_directory)\n    cmd = ['--install-dir', server_directory,\n           '--site-dirs', server_directory,\n           '--always-copy','--always-unzip']\n    cmd.extend(missing_dependencies)\n    setuptools.command.easy_install.main(cmd)\n    instrument_installation()\n\nif missing_dependencies:\n    install_deps()\n\ndel missing_dependencies[:]\n\ntry:\n    import jedi\nexcept ImportError:\n    missing_dependencies.append('>='.join(jedi_dep))\n\ntry:\n    import service_factory\nexcept ImportError:\n    missing_dependencies.append('>='.join(service_factory_dep))\n\n# Try one more time in case if anaconda installation gets broken somehow\nif missing_dependencies:\n    install_deps()\n    import jedi\n    import service_factory\n\n# Setup server.\n\nassert jedi.__version__ >= jedi_dep[1], 'Jedi version should be >= %s, current version: %s' % (jedi_dep[1], jedi.__version__,)\n\nif virtual_environment:\n    virtual_environment = jedi.create_environment(virtual_environment, safe=False)\nelse:\n    virtual_environment = None\n\n# Define JSON-RPC application.\n\nimport functools\nimport threading\n\ndef script_method(f):\n    @functools.wraps(f)\n    def wrapper(source, line, column, path):\n        timer = threading.Timer(30.0, sys.exit)\n        timer.start()\n        result = f(jedi.Script(source, line, column, path, environment=virtual_environment))\n        timer.cancel()\n        return result\n    return wrapper\n\ndef process_definitions(f):\n    @functools.wraps(f)\n    def wrapper(script):\n        definitions = f(script)\n        if len(definitions) == 1 and not definitions[0].module_path:\n            return '%s is defined in %s compiled module' % (\n                definitions[0].name, definitions[0].module_name)\n        return [[definition.module_path,\n                 definition.line,\n                 definition.column,\n                 definition.get_line_code().strip()]\n                for definition in definitions\n                if definition.module_path] or None\n    return wrapper\n\n@script_method\ndef complete(script):\n    return [[definition.name, definition.type]\n            for definition in script.completions()]\n\n@script_method\ndef company_complete(script):\n    return [[definition.name,\n             definition.type,\n             definition.docstring(),\n             definition.module_path,\n             definition.line]\n            for definition in script.completions()]\n\n@script_method\ndef show_doc(script):\n    return [[definition.module_name, definition.docstring()]\n            for definition in script.goto_definitions()]\n\n@script_method\n@process_definitions\ndef goto_definitions(script):\n    return script.goto_definitions()\n\n@script_method\n@process_definitions\ndef goto_assignments(script):\n    return script.goto_assignments()\n\n@script_method\n@process_definitions\ndef usages(script):\n    return script.usages()\n\n@script_method\ndef eldoc(script):\n    signatures = script.call_signatures()\n    if len(signatures) == 1:\n        signature = signatures[0]\n        return [signature.name,\n                signature.index,\n                [param.description[6:] for param in signature.params]]\n\n# Run.\n\napp = [complete, company_complete, show_doc, goto_definitions, goto_assignments, usages, eldoc]\n\nservice_factory.service_factory(app, server_address, 0, 'anaconda_mode port {port}')\n" "~/.emacs.d/anaconda-mode/0.1.13" "0.0.0.0" "/ssh:localhost:/tmp/anaconda-repro-OSgti/home/python-code/venv"))
  start-file-process("anaconda-mode" #<buffer *anaconda-mode*> "python3" "-c" "\nfrom __future__ import print_function\n\n# CLI arguments.\n\nimport sys\n\nassert len(sys.argv) > 3, 'CLI arguments: %s' % sys.argv\n\nserver_directory = sys.argv[-3]\nserver_address = sys.argv[-2]\nvirtual_environment = sys.argv[-1]\n\n# Ensure directory.\n\nimport os\n\nserver_directory = os.path.expanduser(server_directory)\nvirtual_environment = os.path.expanduser(virtual_environment)\n\nif not os.path.exists(server_directory):\n    os.makedirs(server_directory)\n\n# Installation check.\n\njedi_dep = ('jedi', '0.13.0')\nservice_factory_dep = ('service_factory', '0.1.5')\n\nmissing_dependencies = []\n\ndef instrument_installation():\n    for package in (jedi_dep, service_factory_dep):\n        package_is_installed = False\n        for path in os.listdir(server_directory):\n            path = os.path.join(server_directory, path)\n            if path.endswith('.egg') and os.path.isdir(path):\n                if path not in sys.path:\n                    sys.path.insert(0, path)\n                if package[0] in path:\n                    package_is_installed = True\n        if not package_is_installed:\n            missing_dependencies.append('>='.join(package))\n\ninstrument_installation()\n\n# Installation.\n\ndef install_deps():\n    import site\n    import setuptools.command.easy_install\n    site.addsitedir(server_directory)\n    cmd = ['--install-dir', server_directory,\n           '--site-dirs', server_directory,\n           '--always-copy','--always-unzip']\n    cmd.extend(missing_dependencies)\n    setuptools.command.easy_install.main(cmd)\n    instrument_installation()\n\nif missing_dependencies:\n    install_deps()\n\ndel missing_dependencies[:]\n\ntry:\n    import jedi\nexcept ImportError:\n    missing_dependencies.append('>='.join(jedi_dep))\n\ntry:\n    import service_factory\nexcept ImportError:\n    missing_dependencies.append('>='.join(service_factory_dep))\n\n# Try one more time in case if anaconda installation gets broken somehow\nif missing_dependencies:\n    install_deps()\n    import jedi\n    import service_factory\n\n# Setup server.\n\nassert jedi.__version__ >= jedi_dep[1], 'Jedi version should be >= %s, current version: %s' % (jedi_dep[1], jedi.__version__,)\n\nif virtual_environment:\n    virtual_environment = jedi.create_environment(virtual_environment, safe=False)\nelse:\n    virtual_environment = None\n\n# Define JSON-RPC application.\n\nimport functools\nimport threading\n\ndef script_method(f):\n    @functools.wraps(f)\n    def wrapper(source, line, column, path):\n        timer = threading.Timer(30.0, sys.exit)\n        timer.start()\n        result = f(jedi.Script(source, line, column, path, environment=virtual_environment))\n        timer.cancel()\n        return result\n    return wrapper\n\ndef process_definitions(f):\n    @functools.wraps(f)\n    def wrapper(script):\n        definitions = f(script)\n        if len(definitions) == 1 and not definitions[0].module_path:\n            return '%s is defined in %s compiled module' % (\n                definitions[0].name, definitions[0].module_name)\n        return [[definition.module_path,\n                 definition.line,\n                 definition.column,\n                 definition.get_line_code().strip()]\n                for definition in definitions\n                if definition.module_path] or None\n    return wrapper\n\n@script_method\ndef complete(script):\n    return [[definition.name, definition.type]\n            for definition in script.completions()]\n\n@script_method\ndef company_complete(script):\n    return [[definition.name,\n             definition.type,\n             definition.docstring(),\n             definition.module_path,\n             definition.line]\n            for definition in script.completions()]\n\n@script_method\ndef show_doc(script):\n    return [[definition.module_name, definition.docstring()]\n            for definition in script.goto_definitions()]\n\n@script_method\n@process_definitions\ndef goto_definitions(script):\n    return script.goto_definitions()\n\n@script_method\n@process_definitions\ndef goto_assignments(script):\n    return script.goto_assignments()\n\n@script_method\n@process_definitions\ndef usages(script):\n    return script.usages()\n\n@script_method\ndef eldoc(script):\n    signatures = script.call_signatures()\n    if len(signatures) == 1:\n        signature = signatures[0]\n        return [signature.name,\n                signature.index,\n                [param.description[6:] for param in signature.params]]\n\n# Run.\n\napp = [complete, company_complete, show_doc, goto_definitions, goto_assignments, usages, eldoc]\n\nservice_factory.service_factory(app, server_address, 0, 'anaconda_mode port {port}')\n" "~/.emacs.d/anaconda-mode/0.1.13" "0.0.0.0" "/ssh:localhost:/tmp/anaconda-repro-OSgti/home/python-code/venv")
  apply(start-file-process "anaconda-mode" #<buffer *anaconda-mode*> "python3" ("-c" "\nfrom __future__ import print_function\n\n# CLI arguments.\n\nimport sys\n\nassert len(sys.argv) > 3, 'CLI arguments: %s' % sys.argv\n\nserver_directory = sys.argv[-3]\nserver_address = sys.argv[-2]\nvirtual_environment = sys.argv[-1]\n\n# Ensure directory.\n\nimport os\n\nserver_directory = os.path.expanduser(server_directory)\nvirtual_environment = os.path.expanduser(virtual_environment)\n\nif not os.path.exists(server_directory):\n    os.makedirs(server_directory)\n\n# Installation check.\n\njedi_dep = ('jedi', '0.13.0')\nservice_factory_dep = ('service_factory', '0.1.5')\n\nmissing_dependencies = []\n\ndef instrument_installation():\n    for package in (jedi_dep, service_factory_dep):\n        package_is_installed = False\n        for path in os.listdir(server_directory):\n            path = os.path.join(server_directory, path)\n            if path.endswith('.egg') and os.path.isdir(path):\n                if path not in sys.path:\n                    sys.path.insert(0, path)\n                if package[0] in path:\n                    package_is_installed = True\n        if not package_is_installed:\n            missing_dependencies.append('>='.join(package))\n\ninstrument_installation()\n\n# Installation.\n\ndef install_deps():\n    import site\n    import setuptools.command.easy_install\n    site.addsitedir(server_directory)\n    cmd = ['--install-dir', server_directory,\n           '--site-dirs', server_directory,\n           '--always-copy','--always-unzip']\n    cmd.extend(missing_dependencies)\n    setuptools.command.easy_install.main(cmd)\n    instrument_installation()\n\nif missing_dependencies:\n    install_deps()\n\ndel missing_dependencies[:]\n\ntry:\n    import jedi\nexcept ImportError:\n    missing_dependencies.append('>='.join(jedi_dep))\n\ntry:\n    import service_factory\nexcept ImportError:\n    missing_dependencies.append('>='.join(service_factory_dep))\n\n# Try one more time in case if anaconda installation gets broken somehow\nif missing_dependencies:\n    install_deps()\n    import jedi\n    import service_factory\n\n# Setup server.\n\nassert jedi.__version__ >= jedi_dep[1], 'Jedi version should be >= %s, current version: %s' % (jedi_dep[1], jedi.__version__,)\n\nif virtual_environment:\n    virtual_environment = jedi.create_environment(virtual_environment, safe=False)\nelse:\n    virtual_environment = None\n\n# Define JSON-RPC application.\n\nimport functools\nimport threading\n\ndef script_method(f):\n    @functools.wraps(f)\n    def wrapper(source, line, column, path):\n        timer = threading.Timer(30.0, sys.exit)\n        timer.start()\n        result = f(jedi.Script(source, line, column, path, environment=virtual_environment))\n        timer.cancel()\n        return result\n    return wrapper\n\ndef process_definitions(f):\n    @functools.wraps(f)\n    def wrapper(script):\n        definitions = f(script)\n        if len(definitions) == 1 and not definitions[0].module_path:\n            return '%s is defined in %s compiled module' % (\n                definitions[0].name, definitions[0].module_name)\n        return [[definition.module_path,\n                 definition.line,\n                 definition.column,\n                 definition.get_line_code().strip()]\n                for definition in definitions\n                if definition.module_path] or None\n    return wrapper\n\n@script_method\ndef complete(script):\n    return [[definition.name, definition.type]\n            for definition in script.completions()]\n\n@script_method\ndef company_complete(script):\n    return [[definition.name,\n             definition.type,\n             definition.docstring(),\n             definition.module_path,\n             definition.line]\n            for definition in script.completions()]\n\n@script_method\ndef show_doc(script):\n    return [[definition.module_name, definition.docstring()]\n            for definition in script.goto_definitions()]\n\n@script_method\n@process_definitions\ndef goto_definitions(script):\n    return script.goto_definitions()\n\n@script_method\n@process_definitions\ndef goto_assignments(script):\n    return script.goto_assignments()\n\n@script_method\n@process_definitions\ndef usages(script):\n    return script.usages()\n\n@script_method\ndef eldoc(script):\n    signatures = script.call_signatures()\n    if len(signatures) == 1:\n        signature = signatures[0]\n        return [signature.name,\n                signature.index,\n                [param.description[6:] for param in signature.params]]\n\n# Run.\n\napp = [complete, company_complete, show_doc, goto_definitions, goto_assignments, usages, eldoc]\n\nservice_factory.service_factory(app, server_address, 0, 'anaconda_mode port {port}')\n" "~/.emacs.d/anaconda-mode/0.1.13" "0.0.0.0" "/ssh:localhost:/tmp/anaconda-repro-OSgti/home/python-code/venv"))
  pythonic-start-process(:process "anaconda-mode" :cwd nil :buffer #<buffer *anaconda-mode*> :query-on-exit nil :filter #f(compiled-function (process output) #<bytecode 0x1c33b09>) :sentinel #f(compiled-function (process event) #<bytecode 0x1ca585d>) :args ("-c" "\nfrom __future__ import print_function\n\n# CLI arguments.\n\nimport sys\n\nassert len(sys.argv) > 3, 'CLI arguments: %s' % sys.argv\n\nserver_directory = sys.argv[-3]\nserver_address = sys.argv[-2]\nvirtual_environment = sys.argv[-1]\n\n# Ensure directory.\n\nimport os\n\nserver_directory = os.path.expanduser(server_directory)\nvirtual_environment = os.path.expanduser(virtual_environment)\n\nif not os.path.exists(server_directory):\n    os.makedirs(server_directory)\n\n# Installation check.\n\njedi_dep = ('jedi', '0.13.0')\nservice_factory_dep = ('service_factory', '0.1.5')\n\nmissing_dependencies = []\n\ndef instrument_installation():\n    for package in (jedi_dep, service_factory_dep):\n        package_is_installed = False\n        for path in os.listdir(server_directory):\n            path = os.path.join(server_directory, path)\n            if path.endswith('.egg') and os.path.isdir(path):\n                if path not in sys.path:\n                    sys.path.insert(0, path)\n                if package[0] in path:\n                    package_is_installed = True\n        if not package_is_installed:\n            missing_dependencies.append('>='.join(package))\n\ninstrument_installation()\n\n# Installation.\n\ndef install_deps():\n    import site\n    import setuptools.command.easy_install\n    site.addsitedir(server_directory)\n    cmd = ['--install-dir', server_directory,\n           '--site-dirs', server_directory,\n           '--always-copy','--always-unzip']\n    cmd.extend(missing_dependencies)\n    setuptools.command.easy_install.main(cmd)\n    instrument_installation()\n\nif missing_dependencies:\n    install_deps()\n\ndel missing_dependencies[:]\n\ntry:\n    import jedi\nexcept ImportError:\n    missing_dependencies.append('>='.join(jedi_dep))\n\ntry:\n    import service_factory\nexcept ImportError:\n    missing_dependencies.append('>='.join(service_factory_dep))\n\n# Try one more time in case if anaconda installation gets broken somehow\nif missing_dependencies:\n    install_deps()\n    import jedi\n    import service_factory\n\n# Setup server.\n\nassert jedi.__version__ >= jedi_dep[1], 'Jedi version should be >= %s, current version: %s' % (jedi_dep[1], jedi.__version__,)\n\nif virtual_environment:\n    virtual_environment = jedi.create_environment(virtual_environment, safe=False)\nelse:\n    virtual_environment = None\n\n# Define JSON-RPC application.\n\nimport functools\nimport threading\n\ndef script_method(f):\n    @functools.wraps(f)\n    def wrapper(source, line, column, path):\n        timer = threading.Timer(30.0, sys.exit)\n        timer.start()\n        result = f(jedi.Script(source, line, column, path, environment=virtual_environment))\n        timer.cancel()\n        return result\n    return wrapper\n\ndef process_definitions(f):\n    @functools.wraps(f)\n    def wrapper(script):\n        definitions = f(script)\n        if len(definitions) == 1 and not definitions[0].module_path:\n            return '%s is defined in %s compiled module' % (\n                definitions[0].name, definitions[0].module_name)\n        return [[definition.module_path,\n                 definition.line,\n                 definition.column,\n                 definition.get_line_code().strip()]\n                for definition in definitions\n                if definition.module_path] or None\n    return wrapper\n\n@script_method\ndef complete(script):\n    return [[definition.name, definition.type]\n            for definition in script.completions()]\n\n@script_method\ndef company_complete(script):\n    return [[definition.name,\n             definition.type,\n             definition.docstring(),\n             definition.module_path,\n             definition.line]\n            for definition in script.completions()]\n\n@script_method\ndef show_doc(script):\n    return [[definition.module_name, definition.docstring()]\n            for definition in script.goto_definitions()]\n\n@script_method\n@process_definitions\ndef goto_definitions(script):\n    return script.goto_definitions()\n\n@script_method\n@process_definitions\ndef goto_assignments(script):\n    return script.goto_assignments()\n\n@script_method\n@process_definitions\ndef usages(script):\n    return script.usages()\n\n@script_method\ndef eldoc(script):\n    signatures = script.call_signatures()\n    if len(signatures) == 1:\n        signature = signatures[0]\n        return [signature.name,\n                signature.index,\n                [param.description[6:] for param in signature.params]]\n\n# Run.\n\napp = [complete, company_complete, show_doc, goto_definitions, goto_assignments, usages, eldoc]\n\nservice_factory.service_factory(app, server_address, 0, 'anaconda_mode port {port}')\n" "~/.emacs.d/anaconda-mode/0.1.13" "0.0.0.0" "/ssh:localhost:/tmp/anaconda-repro-OSgti/home/python-code/venv"))
  anaconda-mode-bootstrap(#f(compiled-function () #<bytecode 0x1bb18d9>))
  anaconda-mode-start(#f(compiled-function () #<bytecode 0x1bb18d9>))
  anaconda-mode-call("eldoc" anaconda-mode-eldoc-callback)
  anaconda-mode-eldoc-function()
  eldoc-print-current-symbol-info()
  #f(compiled-function () #<bytecode 0x202b97>)()
  apply(#f(compiled-function () #<bytecode 0x202b97>) nil)
  timer-event-handler([t 0 0 500000 nil #f(compiled-function () #<bytecode 0x202b97>) nil idle 0])

@Knusper
Copy link

Knusper commented Dec 9, 2020

I have a similar problem, as a workaround I now disable eldoc mode, since this seems to be the culprit here..

@mathrick
Copy link
Author

I worked around it by disabling pyvenv and using pythonic-activate instead, plus a small hack I wrote to add python restart when the venv is changed: mathrick/mood-emacs@4c4f90e (the function is pythonic-restart-python-on-activate)

@NightMachinery
Copy link

@Knusper commented on Dec 10, 2020, 12:54 AM GMT+3:30:

I have a similar problem, as a workaround I now disable eldoc mode, since this seems to be the culprit here..

How do you disable it? I don't find it in the python mode hook ...

@Knusper
Copy link

Knusper commented Mar 27, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants