jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 262 forks source link

Emacs hangs after a while #709

Open dsaard opened 9 years ago

dsaard commented 9 years ago

Hi there, i´m new to elpy and my emacs hangs after a while.

beginning to type "import argp" works with a tooltip and completion and then no more ...

after writing some lines more emacs hangs completly

strace the emacs process:

[pid 27335] recvmsg(8, 0x7ffd1bfa2490, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27335] poll([{fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=11, events=POLLIN}, {fd=5, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27335] write(15, "{\"id\":36,\"method\":\"get_calltip\","..., 1683) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27335] pselect6(17, [5 7 8 11 13 16], [], NULL, {0, 19999226}, {NULL, 8}) = 0 (Timeout)
[pid 27335] recvmsg(8, 0x7ffd1bfa2490, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27335] poll([{fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=11, events=POLLIN}, {fd=5, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27335] write(15, "{\"id\":36,\"method\":\"get_calltip\","..., 1683) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27335] pselect6(17, [5 7 8 11 13 16], [], NULL, {0, 19999313}, {NULL, 8}) = 1 (in [8], left {0, 1735472})
[pid 27335] --- SIGIO {si_signo=SIGIO, si_code=SI_KERNEL} ---
[pid 27335] rt_sigreturn()              = 1
[pid 27335] recvmsg(8, {msg_name(0)=NULL, msg_iov(1)=[{"U\2\31\210\3277\313\7\3\4\4\0\0\0\0\0\0\0\0\4\4\4\4\4\0\0\3\37%\2\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 32
[pid 27335] recvmsg(8, 0x7ffd1bfa2490, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27335] poll([{fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=11, events=POLLIN}, {fd=5, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27335] recvmsg(8, 0x7ffd1bfa2490, 0) = -1 EAGAIN (Resource temporarily unavailable)

with C+ggg emacs comes back and hangs again C+gggg M+x elpy-rpc-restart and i can write some lines

First i thought with the oh-my-emacs config collection is sometthig wrong, but some behavior with a plain setup

My versions:

Elpy Configuration
Virtualenv........: None
RPC Python........: 2.7.9 (/usr/bin/python)
Interactive Python: ipython (/usr/bin/ipython)
Emacs.............: 24.4.1
Elpy..............: 1.10.0
Jedi..............: 0.9.0
Rope..............: 0.10.3
Importmagic.......: 0.1.3
Autopep8..........: 0.1.3
Syntax checker....: flake8 (/usr/local/bin/flake8)

i checked the related issues but with no success ...

any ideas?

Cheers

Dominik

dsaard commented 9 years ago

I found it.

with:

/usr/local/bin/flake8 --version
2.5.0 (pep8: 1.5.7, pyflakes: 1.0.0, mccabe: 0.3.1) CPython 2.7.9 on Linux

installed elpy stops working

uninstall flake8 and all problems gone .. but flake should be nice ....

forget it, it wasn´t flake8, on my other maschine the syntaxchecker was the case, but not here :(

jorgenschaefer commented 9 years ago

Thanks for the report! This sounds very weird – can you do M-x toggle-debug-on-quit and use C-g again to get out of the locking? This should produce a backtrace, could you post that here? Thank you!

dsaard commented 9 years ago

Here is the debug output

Debugger entered--Lisp error: (quit)
  process-send-string(#<process  *elpy-rpc [project:~/git/apwlinux/aclient/ python:/usr/bin/python]*> "{\"id\":49,\"method\":\"get_calltip\",\"params\":[\"\\/home\\/dominik\\/git\\/apwlinux\\/aclient\\/apwinisync.py\",\"#!\\/usr\\/bin\\/env python\\n\\n# APWLinux ini abgleich fuer [lin]und [for]\\n\\nimport ConfigParser\\nimport argparse\\nimport sys\\nimport dbfread\\n\\nparser = argparse.ArgumentParser(prog=\\\"apwinisync\\\")\\nparser.add_argument(\\\"--aclprefix\\\", help=\\\"APW aclient Benutzerprefix: aclient\\\",\\n                    default=\\\"aclient\\\")\\nparser.add_argument(\\\"--aclnr\\\", help=\\\"Anzahl der APW aclients\\\", default=11)\\nparser.add_argument(\\\"--aclexclude\\\", help=\\\"Excludierte Benutzer\\\")\\nparser.add_argument(\\\"--apwpath\\\", help=\\\"Pfad zur apwinstallation\\\", default=\\\"\\/home\\/praxis\\/a\\/\\\")\\n\\nargs = parser.parse_args()\\n\\naclprefix = args.aclprefix\\naclnr = args.aclnr\\n\\naclients = [aclprefix+str(a).rjust(2, \\\"0\\\") for a in range(1, int(aclnr))]\\n\\nif args.aclexclude:\\n    aclexclude = [aclprefix+str(a).rjust(2, \\\"0\\\") for a in args.aclexclude.split(\\\",\\\")]\\n    for a in aclexclude:\\n        aclients.remove(a)\\n\\n\\nsrcini = ConfigParser.SafeConfigParser()\\ndstini = ConfigParser.SafeConfigParser()\\n\\nsrcini.read(\\\"apw.ini\\\")\\ndstini.read(\\\"apw.ini.new\\\")\\nif not dstini.has_section(\\\"for\\\"):\\n    dstini.add_section(\\\"for\\\")\\n\\nif not dstini.has_section(\\\"lin\\\"):\\n    dstini.add_section(\\\"lin\\\")\\n\\nfor srcfor in srcini.items(\\\"for\\\"):\\n    cfor = str(srcfor[0])\\n    cprt = str(srcfor[1])\\n    dstini.set(\\\"for\\\", cfor, cprt)\\n\\nfor srcfor in srcini.items(\\\"lin\\\"):\\n    clin = str(srcfor[0])\\n    cprt = str(srcfor[1])\\n    dstini.set(\\\"lin\\\", clin, cprt)\\n\\nprint(\\\"Section [for]\\\")\\nfor a in dstini.items(\\\"for\\\"):\\n    print(a)\\n\\nprint(\\\"Section [lin]\\\")\\nfor a in dstini.items(\\\"lin\\\"):\\n    print(a)\\n\\nwith open(\\\"apw.ini.new\\\", \\\"a\\\") as apw:\\n    dstini.write(apw)\\n\\nfrom datetime import time\\n\\ntime.sleept\",1585]}\n")
  elpy-rpc--call("get_calltip" ("/home/dominik/git/apwlinux/aclient/apwinisync.py" #("#!/usr/bin/env python\n\n# APWLinux ini abgleich fuer [lin]und [for]\n\nimport ConfigParser\nimport argparse\nimport sys\nimport dbfread\n\nparser = argparse.ArgumentParser(prog=\"apwinisync\")\nparser.add_argument(\"--aclprefix\", help=\"APW aclient Benutzerprefix: aclient\",\n                    default=\"aclient\")\nparser.add_argument(\"--aclnr\", help=\"Anzahl der APW aclients\", default=11)\nparser.add_argument(\"--aclexclude\", help=\"Excludierte Benutzer\")\nparser.add_argument(\"--apwpath\", help=\"Pfad zur apwinstallation\", default=\"/home/praxis/a/\")\n\nargs = parser.parse_args()\n\naclprefix = args.aclprefix\naclnr = args.aclnr\n\naclients = [aclprefix+str(a).rjust(2, \"0\") for a in range(1, int(aclnr))]\n\nif args.aclexclude:\n    aclexclude = [aclprefix+str(a).rjust(2, \"0\") for a in args.aclexclude.split(\",\")]\n    for a in aclexclude:\n        aclients.remove(a)\n\n\nsrcini = ConfigParser.SafeConfigParser()\ndstini = ConfigParser.SafeConfigParser()\n\nsrcini.read(\"apw.ini\")\ndstini.read(\"apw.ini.new\")\nif not dstini.has_section(\"for\"):\n    dstini.add_section(\"for\")\n\nif not dstini.has_section(\"lin\"):\n    dstini.add_section(\"lin\")\n\nfor srcfor in srcini.items(\"for\"):\n    cfor = str(srcfor[0])\n    cprt = str(srcfor[1])\n    dstini.set(\"for\", cfor, cprt)\n\nfor srcfor in srcini.items(\"lin\"):\n    clin = str(srcfor[0])\n    cprt = str(srcfor[1])\n    dstini.set(\"lin\", clin, cprt)\n\nprint(\"Section [for]\")\nfor a in dstini.items(\"for\"):\n    print(a)\n\nprint(\"Section [lin]\")\nfor a in dstini.items(\"lin\"):\n    print(a)\n\nwith open(\"apw.ini.new\", \"a\") as apw:\n    dstini.write(apw)\n\nfrom datetime import time\n\ntime.sleept" 0 1 (fontified t face font-lock-comment-delimiter-face) 1 22 (fontified t face font-lock-comment-face) 22 23 (fontified t) 23 25 (fontified t face font-lock-comment-delimiter-face) 25 67 (fontified t face font-lock-comment-face) 67 68 (fontified t) 68 74 (fontified t face font-lock-keyword-face) 74 88 (fontified t) 88 94 (fontified t face font-lock-keyword-face) 94 104 (fontified t) 104 110 (fontified t face font-lock-keyword-face) 110 115 (fontified t) 115 121 (fontified t face font-lock-keyword-face) 121 131 (fontified t) 131 137 (fontified t face font-lock-variable-name-face) 137 169 (fontified t) 169 170 (syntax-table (15) fontified t face font-lock-string-face) 170 180 (fontified t face font-lock-string-face) 180 181 (syntax-table (15) fontified t face font-lock-string-face) 181 203 (fontified t) 203 204 (syntax-table (15) fontified t face font-lock-string-face) 204 215 (fontified t face font-lock-string-face) 215 216 (syntax-table (15) fontified t face font-lock-string-face) 216 218 (fontified t) 218 222 (fontified t face font-lock-builtin-face) 222 223 (fontified t) 223 224 (syntax-table (15) fontified t face font-lock-string-face) 224 259 (fontified t face font-lock-string-face) 259 260 (syntax-table (15) fontified t face font-lock-string-face) 260 290 (fontified t) 290 291 (syntax-table (15) fontified t face font-lock-string-face) 291 298 (fontified t face font-lock-string-face) 298 299 (syntax-table (15) fontified t face font-lock-string-face) 299 321 (fontified t) 321 322 (syntax-table (15) fontified t face font-lock-string-face) 322 329 (fontified t face font-lock-string-face) 329 330 (syntax-table (15) fontified t face font-lock-string-face) 330 332 (fontified t) 332 336 (fontified t face font-lock-builtin-face) 336 337 (fontified t) 337 338 (syntax-table (15) fontified t face font-lock-string-face) 338 361 (fontified t face font-lock-string-face) 361 362 (syntax-table (15) fontified t face font-lock-string-face) 362 396 (fontified t) 396 397 (syntax-table (15) fontified t face font-lock-string-face) 397 409 (fontified t face font-lock-string-face) 409 410 (syntax-table (15) fontified t face font-lock-string-face) 410 412 (fontified t) 412 416 (fontified t face font-lock-builtin-face) 416 417 (fontified t) 417 418 (syntax-table (15) fontified t face font-lock-string-face) 418 438 (fontified t face font-lock-string-face) 438 439 (syntax-table (15) fontified t face font-lock-string-face) 439 461 (fontified t) 461 462 (syntax-table (15) fontified t face font-lock-string-face) 462 471 (fontified t face font-lock-string-face) 471 472 (syntax-table (15) fontified t face font-lock-string-face) 472 474 (fontified t) 474 478 (fontified t face font-lock-builtin-face) 478 479 (fontified t) 479 480 (syntax-table (15) fontified t face font-lock-string-face) 480 504 (fontified t face font-lock-string-face) 504 505 (syntax-table (15) fontified t face font-lock-string-face) 505 515 (fontified t) 515 516 (syntax-table (15) fontified t face font-lock-string-face) 516 531 (fontified t face font-lock-string-face) 531 532 (syntax-table (15) fontified t face font-lock-string-face) 532 534 (fontified t) 534 535 (fontified t) 535 539 (fontified t face font-lock-variable-name-face) 539 563 (fontified t) 563 572 (fontified t face font-lock-variable-name-face) 572 590 (fontified t) 590 595 (fontified t face font-lock-variable-name-face) 595 610 (fontified t) 610 618 (fontified t face font-lock-variable-name-face) 618 632 (fontified t) 632 635 (fontified t face font-lock-builtin-face) 635 648 (fontified t) 648 649 (syntax-table (15) fontified t face font-lock-string-face) 649 650 (fontified t face font-lock-string-face) 650 651 (syntax-table (15) fontified t face font-lock-string-face) 651 653 (fontified t) 653 656 (fontified t face font-lock-keyword-face) 656 659 (fontified t) 659 661 (fontified t face font-lock-keyword-face) 661 662 (fontified t) 662 667 (fontified t face font-lock-builtin-face) 667 671 (fontified t) 671 674 (fontified t face font-lock-builtin-face) 674 685 (fontified t) 685 687 (fontified t face font-lock-keyword-face) 687 709 (fontified t) 709 719 (fontified t face font-lock-variable-name-face) 719 733 (fontified t) 733 736 (fontified t face font-lock-builtin-face) 736 749 (fontified t) 749 750 (fontified t syntax-table (15) face font-lock-string-face) 750 751 (fontified t face font-lock-string-face) 751 752 (fontified t syntax-table (15) face font-lock-string-face) 752 754 (fontified t) 754 757 (fontified t face font-lock-keyword-face) 757 760 (fontified t) 760 762 (fontified t face font-lock-keyword-face) 762 785 (fontified t) 785 786 (fontified t syntax-table (15) face font-lock-string-face) 786 787 (fontified t face font-lock-string-face) 787 788 (fontified t syntax-table (15) face font-lock-string-face) 788 795 (fontified t) 795 798 (fontified t face font-lock-keyword-face) 798 801 (fontified t) 801 803 (fontified t face font-lock-keyword-face) 803 845 (fontified t) 845 851 (fontified t face font-lock-variable-name-face) 851 886 (fontified t) 886 892 (fontified t face font-lock-variable-name-face) 892 940 (fontified t) 940 941 (fontified t syntax-table (15) face font-lock-string-face) 941 948 (fontified t face font-lock-string-face) 948 949 (fontified t syntax-table (15) face font-lock-string-face) 949 963 (fontified t) 963 964 (fontified t syntax-table (15) face font-lock-string-face) 964 975 (fontified t face font-lock-string-face) 975 976 (fontified t syntax-table (15) face font-lock-string-face) 976 978 (fontified t) 978 980 (fontified t face font-lock-keyword-face) 980 981 (fontified t) 981 984 (fontified t face font-lock-keyword-face) 984 1004 (fontified t) 1004 1005 (fontified t syntax-table (15) face font-lock-string-face) 1005 1008 (fontified t face font-lock-string-face) 1008 1009 (fontified t syntax-table (15) face font-lock-string-face) 1009 1035 (fontified t) 1035 1036 (fontified t syntax-table (15) face font-lock-string-face) 1036 1039 (fontified t face font-lock-string-face) 1039 1040 (fontified t syntax-table (15) face font-lock-string-face) 1040 1042 (fontified t) 1042 1043 (fontified t) 1043 1045 (fontified t face font-lock-keyword-face) 1045 1046 (fontified t) 1046 1049 (fontified t face font-lock-keyword-face) 1049 1069 (fontified t) 1069 1070 (fontified t syntax-table (15) face font-lock-string-face) 1070 1073 (fontified t face font-lock-string-face) 1073 1074 (fontified t syntax-table (15) face font-lock-string-face) 1074 1100 (fontified t) 1100 1101 (fontified t syntax-table (15) face font-lock-string-face) 1101 1104 (fontified t face font-lock-string-face) 1104 1105 (fontified t syntax-table (15) face font-lock-string-face) 1105 1108 (fontified t) 1108 1111 (fontified t face font-lock-keyword-face) 1111 1119 (fontified t) 1119 1121 (fontified t face font-lock-keyword-face) 1121 1135 (fontified t) 1135 1136 (fontified t syntax-table (15) face font-lock-string-face) 1136 1139 (fontified t face font-lock-string-face) 1139 1140 (fontified t syntax-table (15) face font-lock-string-face) 1140 1147 (fontified t) 1147 1151 (fontified t face font-lock-variable-name-face) 1151 1154 (fontified t) 1154 1157 (fontified t face font-lock-builtin-face) 1157 1173 (fontified t) 1173 1177 (fontified t face font-lock-variable-name-face) 1177 1180 (fontified t) 1180 1183 (fontified t face font-lock-builtin-face) 1183 1206 (fontified t) 1206 1209 (fontified t face font-lock-builtin-face) 1209 1210 (fontified t) 1210 1211 (fontified t syntax-table (15) face font-lock-string-face) 1211 1214 (fontified t face font-lock-string-face) 1214 1215 (fontified t syntax-table (15) face font-lock-string-face) 1215 1230 (fontified t) 1230 1233 (fontified t face font-lock-keyword-face) 1233 1241 (fontified t) 1241 1243 (fontified t face font-lock-keyword-face) 1243 1257 (fontified t) 1257 1258 (fontified t syntax-table (15) face font-lock-string-face) 1258 1261 (fontified t face font-lock-string-face) 1261 1262 (fontified t syntax-table (15) face font-lock-string-face) 1262 1269 (fontified t) 1269 1273 (fontified t face font-lock-variable-name-face) 1273 1276 (fontified t) 1276 1279 (fontified t face font-lock-builtin-face) 1279 1295 (fontified t) 1295 1299 (fontified t face font-lock-variable-name-face) 1299 1302 (fontified t) 1302 1305 (fontified t face font-lock-builtin-face) 1305 1328 (fontified t) 1328 1331 (fontified t face font-lock-builtin-face) 1331 1332 (fontified t) 1332 1333 (fontified t syntax-table (15) face font-lock-string-face) 1333 1336 (fontified t face font-lock-string-face) 1336 1337 (fontified t syntax-table (15) face font-lock-string-face) 1337 1352 (fontified t) 1352 1357 (fontified t face font-lock-keyword-face) 1357 1358 (fontified t) 1358 1359 (fontified t syntax-table (15) face font-lock-string-face) 1359 1372 (fontified t face font-lock-string-face) 1372 1373 (fontified t syntax-table (15) face font-lock-string-face) 1373 1375 (fontified t) 1375 1378 (fontified t face font-lock-keyword-face) 1378 1381 (fontified t) 1381 1383 (fontified t face font-lock-keyword-face) 1383 1397 (fontified t) 1397 1398 (fontified t syntax-table (15) face font-lock-string-face) 1398 1401 (fontified t face font-lock-string-face) 1401 1402 (fontified t syntax-table (15) face font-lock-string-face) 1402 1409 (fontified t) 1409 1414 (fontified t face font-lock-keyword-face) 1414 1419 (fontified t) 1419 1424 (fontified t face font-lock-keyword-face) 1424 1425 (fontified t) 1425 1426 (fontified t syntax-table (15) face font-lock-string-face) 1426 1439 (fontified t face font-lock-string-face) 1439 1440 (fontified t syntax-table (15) face font-lock-string-face) 1440 1442 (fontified t) 1442 1445 (fontified t face font-lock-keyword-face) 1445 1448 (fontified t) 1448 1450 (fontified t face font-lock-keyword-face) 1450 1464 (fontified t) 1464 1465 (fontified t syntax-table (15) face font-lock-string-face) 1465 1468 (fontified t face font-lock-string-face) 1468 1469 (fontified t syntax-table (15) face font-lock-string-face) 1469 1476 (fontified t) 1476 1481 (fontified t face font-lock-keyword-face) 1481 1486 (fontified t) 1486 1490 (fontified t face font-lock-keyword-face) 1490 1491 (fontified t) 1491 1495 (fontified t face font-lock-builtin-face) 1495 1496 (fontified t) 1496 1497 (fontified t syntax-table (15) face font-lock-string-face) 1497 1508 (fontified t face font-lock-string-face) 1508 1509 (fontified t syntax-table (15) face font-lock-string-face) 1509 1511 (fontified t) 1511 1512 (fontified t syntax-table (15) face font-lock-string-face) 1512 1513 (fontified t face font-lock-string-face) 1513 1514 (fontified t syntax-table (15) face font-lock-string-face) 1514 1516 (fontified t) 1516 1518 (fontified t face font-lock-keyword-face) 1518 1546 (fontified t) 1546 1547 (fontified t) 1547 1551 (fontified t face font-lock-keyword-face) 1551 1561 (fontified t) 1561 1567 (fontified t face font-lock-keyword-face) 1567 1573 (fontified t) 1573 1574 (fontified t) 1574 1585 (fontified t)) 1585) #[257 "" [elpy-eldoc-show-current-function eldoc-message python-info-current-defun format "In: %s()" name index params propertize face eldoc-highlight-function-argument "%s(%s)" mapconcat identity ", "] 12 "\n\n(fn CALLTIP)"] elpy-rpc--default-error-callback)
  elpy-rpc("get_calltip" ("/home/dominik/git/apwlinux/aclient/apwinisync.py" #("#!/usr/bin/env python\n\n# APWLinux ini abgleich fuer [lin]und [for]\n\nimport ConfigParser\nimport argparse\nimport sys\nimport dbfread\n\nparser = argparse.ArgumentParser(prog=\"apwinisync\")\nparser.add_argument(\"--aclprefix\", help=\"APW aclient Benutzerprefix: aclient\",\n                    default=\"aclient\")\nparser.add_argument(\"--aclnr\", help=\"Anzahl der APW aclients\", default=11)\nparser.add_argument(\"--aclexclude\", help=\"Excludierte Benutzer\")\nparser.add_argument(\"--apwpath\", help=\"Pfad zur apwinstallation\", default=\"/home/praxis/a/\")\n\nargs = parser.parse_args()\n\naclprefix = args.aclprefix\naclnr = args.aclnr\n\naclients = [aclprefix+str(a).rjust(2, \"0\") for a in range(1, int(aclnr))]\n\nif args.aclexclude:\n    aclexclude = [aclprefix+str(a).rjust(2, \"0\") for a in args.aclexclude.split(\",\")]\n    for a in aclexclude:\n        aclients.remove(a)\n\n\nsrcini = ConfigParser.SafeConfigParser()\ndstini = ConfigParser.SafeConfigParser()\n\nsrcini.read(\"apw.ini\")\ndstini.read(\"apw.ini.new\")\nif not dstini.has_section(\"for\"):\n    dstini.add_section(\"for\")\n\nif not dstini.has_section(\"lin\"):\n    dstini.add_section(\"lin\")\n\nfor srcfor in srcini.items(\"for\"):\n    cfor = str(srcfor[0])\n    cprt = str(srcfor[1])\n    dstini.set(\"for\", cfor, cprt)\n\nfor srcfor in srcini.items(\"lin\"):\n    clin = str(srcfor[0])\n    cprt = str(srcfor[1])\n    dstini.set(\"lin\", clin, cprt)\n\nprint(\"Section [for]\")\nfor a in dstini.items(\"for\"):\n    print(a)\n\nprint(\"Section [lin]\")\nfor a in dstini.items(\"lin\"):\n    print(a)\n\nwith open(\"apw.ini.new\", \"a\") as apw:\n    dstini.write(apw)\n\nfrom datetime import time\n\ntime.sleept" 0 1 (fontified t face font-lock-comment-delimiter-face) 1 22 (fontified t face font-lock-comment-face) 22 23 (fontified t) 23 25 (fontified t face font-lock-comment-delimiter-face) 25 67 (fontified t face font-lock-comment-face) 67 68 (fontified t) 68 74 (fontified t face font-lock-keyword-face) 74 88 (fontified t) 88 94 (fontified t face font-lock-keyword-face) 94 104 (fontified t) 104 110 (fontified t face font-lock-keyword-face) 110 115 (fontified t) 115 121 (fontified t face font-lock-keyword-face) 121 131 (fontified t) 131 137 (fontified t face font-lock-variable-name-face) 137 169 (fontified t) 169 170 (syntax-table (15) fontified t face font-lock-string-face) 170 180 (fontified t face font-lock-string-face) 180 181 (syntax-table (15) fontified t face font-lock-string-face) 181 203 (fontified t) 203 204 (syntax-table (15) fontified t face font-lock-string-face) 204 215 (fontified t face font-lock-string-face) 215 216 (syntax-table (15) fontified t face font-lock-string-face) 216 218 (fontified t) 218 222 (fontified t face font-lock-builtin-face) 222 223 (fontified t) 223 224 (syntax-table (15) fontified t face font-lock-string-face) 224 259 (fontified t face font-lock-string-face) 259 260 (syntax-table (15) fontified t face font-lock-string-face) 260 290 (fontified t) 290 291 (syntax-table (15) fontified t face font-lock-string-face) 291 298 (fontified t face font-lock-string-face) 298 299 (syntax-table (15) fontified t face font-lock-string-face) 299 321 (fontified t) 321 322 (syntax-table (15) fontified t face font-lock-string-face) 322 329 (fontified t face font-lock-string-face) 329 330 (syntax-table (15) fontified t face font-lock-string-face) 330 332 (fontified t) 332 336 (fontified t face font-lock-builtin-face) 336 337 (fontified t) 337 338 (syntax-table (15) fontified t face font-lock-string-face) 338 361 (fontified t face font-lock-string-face) 361 362 (syntax-table (15) fontified t face font-lock-string-face) 362 396 (fontified t) 396 397 (syntax-table (15) fontified t face font-lock-string-face) 397 409 (fontified t face font-lock-string-face) 409 410 (syntax-table (15) fontified t face font-lock-string-face) 410 412 (fontified t) 412 416 (fontified t face font-lock-builtin-face) 416 417 (fontified t) 417 418 (syntax-table (15) fontified t face font-lock-string-face) 418 438 (fontified t face font-lock-string-face) 438 439 (syntax-table (15) fontified t face font-lock-string-face) 439 461 (fontified t) 461 462 (syntax-table (15) fontified t face font-lock-string-face) 462 471 (fontified t face font-lock-string-face) 471 472 (syntax-table (15) fontified t face font-lock-string-face) 472 474 (fontified t) 474 478 (fontified t face font-lock-builtin-face) 478 479 (fontified t) 479 480 (syntax-table (15) fontified t face font-lock-string-face) 480 504 (fontified t face font-lock-string-face) 504 505 (syntax-table (15) fontified t face font-lock-string-face) 505 515 (fontified t) 515 516 (syntax-table (15) fontified t face font-lock-string-face) 516 531 (fontified t face font-lock-string-face) 531 532 (syntax-table (15) fontified t face font-lock-string-face) 532 534 (fontified t) 534 535 (fontified t) 535 539 (fontified t face font-lock-variable-name-face) 539 563 (fontified t) 563 572 (fontified t face font-lock-variable-name-face) 572 590 (fontified t) 590 595 (fontified t face font-lock-variable-name-face) 595 610 (fontified t) 610 618 (fontified t face font-lock-variable-name-face) 618 632 (fontified t) 632 635 (fontified t face font-lock-builtin-face) 635 648 (fontified t) 648 649 (syntax-table (15) fontified t face font-lock-string-face) 649 650 (fontified t face font-lock-string-face) 650 651 (syntax-table (15) fontified t face font-lock-string-face) 651 653 (fontified t) 653 656 (fontified t face font-lock-keyword-face) 656 659 (fontified t) 659 661 (fontified t face font-lock-keyword-face) 661 662 (fontified t) 662 667 (fontified t face font-lock-builtin-face) 667 671 (fontified t) 671 674 (fontified t face font-lock-builtin-face) 674 685 (fontified t) 685 687 (fontified t face font-lock-keyword-face) 687 709 (fontified t) 709 719 (fontified t face font-lock-variable-name-face) 719 733 (fontified t) 733 736 (fontified t face font-lock-builtin-face) 736 749 (fontified t) 749 750 (fontified t syntax-table (15) face font-lock-string-face) 750 751 (fontified t face font-lock-string-face) 751 752 (fontified t syntax-table (15) face font-lock-string-face) 752 754 (fontified t) 754 757 (fontified t face font-lock-keyword-face) 757 760 (fontified t) 760 762 (fontified t face font-lock-keyword-face) 762 785 (fontified t) 785 786 (fontified t syntax-table (15) face font-lock-string-face) 786 787 (fontified t face font-lock-string-face) 787 788 (fontified t syntax-table (15) face font-lock-string-face) 788 795 (fontified t) 795 798 (fontified t face font-lock-keyword-face) 798 801 (fontified t) 801 803 (fontified t face font-lock-keyword-face) 803 845 (fontified t) 845 851 (fontified t face font-lock-variable-name-face) 851 886 (fontified t) 886 892 (fontified t face font-lock-variable-name-face) 892 940 (fontified t) 940 941 (fontified t syntax-table (15) face font-lock-string-face) 941 948 (fontified t face font-lock-string-face) 948 949 (fontified t syntax-table (15) face font-lock-string-face) 949 963 (fontified t) 963 964 (fontified t syntax-table (15) face font-lock-string-face) 964 975 (fontified t face font-lock-string-face) 975 976 (fontified t syntax-table (15) face font-lock-string-face) 976 978 (fontified t) 978 980 (fontified t face font-lock-keyword-face) 980 981 (fontified t) 981 984 (fontified t face font-lock-keyword-face) 984 1004 (fontified t) 1004 1005 (fontified t syntax-table (15) face font-lock-string-face) 1005 1008 (fontified t face font-lock-string-face) 1008 1009 (fontified t syntax-table (15) face font-lock-string-face) 1009 1035 (fontified t) 1035 1036 (fontified t syntax-table (15) face font-lock-string-face) 1036 1039 (fontified t face font-lock-string-face) 1039 1040 (fontified t syntax-table (15) face font-lock-string-face) 1040 1042 (fontified t) 1042 1043 (fontified t) 1043 1045 (fontified t face font-lock-keyword-face) 1045 1046 (fontified t) 1046 1049 (fontified t face font-lock-keyword-face) 1049 1069 (fontified t) 1069 1070 (fontified t syntax-table (15) face font-lock-string-face) 1070 1073 (fontified t face font-lock-string-face) 1073 1074 (fontified t syntax-table (15) face font-lock-string-face) 1074 1100 (fontified t) 1100 1101 (fontified t syntax-table (15) face font-lock-string-face) 1101 1104 (fontified t face font-lock-string-face) 1104 1105 (fontified t syntax-table (15) face font-lock-string-face) 1105 1108 (fontified t) 1108 1111 (fontified t face font-lock-keyword-face) 1111 1119 (fontified t) 1119 1121 (fontified t face font-lock-keyword-face) 1121 1135 (fontified t) 1135 1136 (fontified t syntax-table (15) face font-lock-string-face) 1136 1139 (fontified t face font-lock-string-face) 1139 1140 (fontified t syntax-table (15) face font-lock-string-face) 1140 1147 (fontified t) 1147 1151 (fontified t face font-lock-variable-name-face) 1151 1154 (fontified t) 1154 1157 (fontified t face font-lock-builtin-face) 1157 1173 (fontified t) 1173 1177 (fontified t face font-lock-variable-name-face) 1177 1180 (fontified t) 1180 1183 (fontified t face font-lock-builtin-face) 1183 1206 (fontified t) 1206 1209 (fontified t face font-lock-builtin-face) 1209 1210 (fontified t) 1210 1211 (fontified t syntax-table (15) face font-lock-string-face) 1211 1214 (fontified t face font-lock-string-face) 1214 1215 (fontified t syntax-table (15) face font-lock-string-face) 1215 1230 (fontified t) 1230 1233 (fontified t face font-lock-keyword-face) 1233 1241 (fontified t) 1241 1243 (fontified t face font-lock-keyword-face) 1243 1257 (fontified t) 1257 1258 (fontified t syntax-table (15) face font-lock-string-face) 1258 1261 (fontified t face font-lock-string-face) 1261 1262 (fontified t syntax-table (15) face font-lock-string-face) 1262 1269 (fontified t) 1269 1273 (fontified t face font-lock-variable-name-face) 1273 1276 (fontified t) 1276 1279 (fontified t face font-lock-builtin-face) 1279 1295 (fontified t) 1295 1299 (fontified t face font-lock-variable-name-face) 1299 1302 (fontified t) 1302 1305 (fontified t face font-lock-builtin-face) 1305 1328 (fontified t) 1328 1331 (fontified t face font-lock-builtin-face) 1331 1332 (fontified t) 1332 1333 (fontified t syntax-table (15) face font-lock-string-face) 1333 1336 (fontified t face font-lock-string-face) 1336 1337 (fontified t syntax-table (15) face font-lock-string-face) 1337 1352 (fontified t) 1352 1357 (fontified t face font-lock-keyword-face) 1357 1358 (fontified t) 1358 1359 (fontified t syntax-table (15) face font-lock-string-face) 1359 1372 (fontified t face font-lock-string-face) 1372 1373 (fontified t syntax-table (15) face font-lock-string-face) 1373 1375 (fontified t) 1375 1378 (fontified t face font-lock-keyword-face) 1378 1381 (fontified t) 1381 1383 (fontified t face font-lock-keyword-face) 1383 1397 (fontified t) 1397 1398 (fontified t syntax-table (15) face font-lock-string-face) 1398 1401 (fontified t face font-lock-string-face) 1401 1402 (fontified t syntax-table (15) face font-lock-string-face) 1402 1409 (fontified t) 1409 1414 (fontified t face font-lock-keyword-face) 1414 1419 (fontified t) 1419 1424 (fontified t face font-lock-keyword-face) 1424 1425 (fontified t) 1425 1426 (fontified t syntax-table (15) face font-lock-string-face) 1426 1439 (fontified t face font-lock-string-face) 1439 1440 (fontified t syntax-table (15) face font-lock-string-face) 1440 1442 (fontified t) 1442 1445 (fontified t face font-lock-keyword-face) 1445 1448 (fontified t) 1448 1450 (fontified t face font-lock-keyword-face) 1450 1464 (fontified t) 1464 1465 (fontified t syntax-table (15) face font-lock-string-face) 1465 1468 (fontified t face font-lock-string-face) 1468 1469 (fontified t syntax-table (15) face font-lock-string-face) 1469 1476 (fontified t) 1476 1481 (fontified t face font-lock-keyword-face) 1481 1486 (fontified t) 1486 1490 (fontified t face font-lock-keyword-face) 1490 1491 (fontified t) 1491 1495 (fontified t face font-lock-builtin-face) 1495 1496 (fontified t) 1496 1497 (fontified t syntax-table (15) face font-lock-string-face) 1497 1508 (fontified t face font-lock-string-face) 1508 1509 (fontified t syntax-table (15) face font-lock-string-face) 1509 1511 (fontified t) 1511 1512 (fontified t syntax-table (15) face font-lock-string-face) 1512 1513 (fontified t face font-lock-string-face) 1513 1514 (fontified t syntax-table (15) face font-lock-string-face) 1514 1516 (fontified t) 1516 1518 (fontified t face font-lock-keyword-face) 1518 1546 (fontified t) 1546 1547 (fontified t) 1547 1551 (fontified t face font-lock-keyword-face) 1551 1561 (fontified t) 1561 1567 (fontified t face font-lock-keyword-face) 1567 1573 (fontified t) 1573 1574 (fontified t) 1574 1585 (fontified t)) 1585) #[257 "" [elpy-eldoc-show-current-function eldoc-message python-info-current-defun format "In: %s()" name index params propertize face eldoc-highlight-function-argument "%s(%s)" mapconcat identity ", "] 12 "\n\n(fn CALLTIP)"] nil)
  elpy-rpc-get-calltip(#[257 "" [elpy-eldoc-show-current-function eldoc-message python-info-current-defun format "In: %s()" name index params propertize face eldoc-highlight-function-argument "%s(%s)" mapconcat identity ", "] 12 "\n\n(fn CALLTIP)"])
  elpy-eldoc-documentation()
  #[0 "" [eldoc-last-message eldoc-documentation-function eldoc-display-message-p eldoc-message nil eldoc-current-symbol eldoc-fnsym-in-current-sexp apply eldoc-get-fnsym-args-string eldoc-get-var-docstring] 5 "\n\n(fn)"]()
  funcall(#[0 "" [eldoc-last-message eldoc-documentation-function eldoc-display-message-p eldoc-message nil eldoc-current-symbol eldoc-fnsym-in-current-sexp apply eldoc-get-fnsym-args-string eldoc-get-var-docstring] 5 "\n\n(fn)"])
  eldoc-print-current-symbol-info()
  #[0 "" [eldoc-mode eldoc-print-current-symbol-info] 1 "\n\n(fn)"]()
  apply(#[0 "" [eldoc-mode eldoc-print-current-symbol-info] 1 "\n\n(fn)"] nil)
  byte-code("r" [timer apply 5 6] 4)
  timer-event-handler([t 0 0 500000 t #[0 "" [eldoc-mode eldoc-print-current-symbol-info] 1 "\n\n(fn)"] nil idle 0])

I removed the controlsequences ...

jorgenschaefer commented 9 years ago

Thank you! Emacs is apparently hanging trying to send data to the Elpy process. Which would indicate that Elpy is not actually reading data, but hanging in some loop.

When this happens, can you check with top (and P) whether the Elpy process is consuming 100% CPU? Either way, could you do an strace like you did for Emacs on that process?

I'm suspecting Rope as the primary culprit, but I could be wrong. If you want, try uninstalling Rope and see if that fixes the problem? :-)

Sorry for this somewhat aimless debugging here. This is a weird problem.

dsaard commented 9 years ago

Hi,

rope is removed now

strace

strace -f -p 22358
Process 22358 attached with 2 threads
[pid 22361] futex(0x7fb3f00d1568, FUTEX_WAIT, 145, NULL <unfinished ...>
[pid 22358] futex(0x229b630, FUTEX_WAIT_PRIVATE, 0, NULL^CProcess 22358 detached
 <detached ...>
Process 22361 detached

But none 100% usage

jorgenschaefer commented 9 years ago

Same problem without Rope? Did you M-x elpy-rpc-restart?

That confuses me a lot now. The Elpy process you show does not actually do anything, so it should keep reading from stdin. And as such, Emacs should not block.

I'm afraid I'm at a loss there :-(

dsaard commented 9 years ago

yes same problem without rope, i started emacs completly new

first i thought i has to do with the oh-my-emacs config package, but the same affect with a new plain setup and your installation howto ....

when i start with an empty test.py, completion works for 2 lines, after some lines more nothing ... happens ... some lines more and it hangs.

if i open a file with about 50 lines it happens faster that emacs hangs

jorgenschaefer commented 9 years ago

I'm afraid I'm completely at a loss here. Sorry. :-(

chenl commented 8 years ago

I see the same thing @dsaard describe.

danielfett commented 8 years ago

Same problem here, using emacs 25.1.50.2 on Ubuntu 14.04, latest version of elpy. Output after toggle-debug-on-quit looks similar. If I can provide any other helpful input, please let me know.

jorgenschaefer commented 8 years ago

Thank you – could you post the exact traceback, please?

Also, what file system is this on?

danielfett commented 8 years ago

ext4 file system mounted with relatime. Traceback was sent via email.

jorgenschaefer commented 8 years ago

@webhamster sent me the backlog in private mail, the lock happens in the same place: process-send-string. That's incredibly confusing. That can only mean that Elpy's input is blocked and it does not accept further input, so it's consuming slower than it receives data. But that should mean the Elpy process is using up all CPU. Apparently, it isn't.

@webhamster, can you confirm that? The Elpy process is not consuming CPU time?

danielfett commented 8 years ago

Yes, can confirm, no significant CPU load caused by either emacs or elpy process.

jorgenschaefer commented 8 years ago

Yay. Shotgun debugging! To verify if this is really the problem, please evaluate this form. The *Messages* buffer then will contain messages listing the duration of each such call. Does the duration increase over time, and is comparatively large when Emacs has locked up?

(defun elpy-rpc--call (method-name params success error)
  "Call METHOD-NAME with PARAMS in the current RPC backend.                     

When a result is available, SUCCESS will be called with that                    
value as its sole argument. If an error occurs, ERROR will be                   
called with the error list.                                                     

Returns a PROMISE object."
  (let ((start (float-time))
        (promise (elpy-promise success error)))
    (with-current-buffer (elpy-rpc--get-rpc-buffer)
      (setq elpy-rpc--call-id (1+ elpy-rpc--call-id)
            elpy-rpc--last-call (float-time))
      (elpy-rpc--register-callback elpy-rpc--call-id promise)
      (process-send-string
       (get-buffer-process (current-buffer))
       (concat (json-encode `((id . ,elpy-rpc--call-id)
                              (method . ,method-name)
                              (params . ,params)))
               "\n")))
    (message "elpy-rpc--call duration %s" (- (float-time) start))
    promise))
danielfett commented 8 years ago

Will run the debug script as soon as the next lockup happens (restarted elpy just now).

NB: strace should show new output when I scroll through a file (it should show that the get_calltip request and others are received, right)?

Because mine does not. This is the only strace output directly relating to elpy since elpy was started. Since then, nothing happened. [pid 23354] lstat("/home/daniel/.emacs.d/elpa/elpy-20160131.118/elpy/main.py", {st_mode=S_IFREG|0644, st_size=551, ...}) = 0 [pid 23354] futex(0x7facf0903a04, FUTEX_WAIT_PRIVATE, 1, NULL <unfinished ...> [pid 23351] <... read resumed> "{\"id\":3,\"method\":\"get_calltip\",\""..., 4096) = 160 [pid 23351] futex(0x1814640, FUTEX_WAIT_PRIVATE, 0, NULL

jorgenschaefer commented 8 years ago

Huh. That's really strange.

What's the value of default-process-coding-system in Emacs and os.linesep in Python?

danielfett commented 8 years ago

Emacs: (utf-8-unix . utf-8-unix) Python: '\n'

jorgenschaefer commented 8 years ago

Ok, that's not the problem, then. I remain confused! :-)

danielfett commented 8 years ago

Well, I tried the debug script above, but it does not create any output when elpy has crashed and I have to abort with C-g.

jorgenschaefer commented 8 years ago

It should cause output when Elpy tries to send more stuff to the backend. As in, if you have to C-g things, evaluate that, and continue to work, it should emit things to *Messages*. Or does Emacs lock up right away again when you go to a Python buffer?

danielfett commented 8 years ago

This is what it looked like: elpy-rpc--call duration 0.0004696846008300781 <-- non-crashing output elpy-rpc--call duration 0.0009064674377441406 <-- non-crashing output, at the next cursor movement the crash happened Quit [3 times] <-- I pressed C-g ... <- other unrelated output

To help with debugging, I added the following lines into read_json in elpy/rpc.py:

     with open('/tmp/elpy-debug-python-server.log', 'a') as f:
        f.write(line[:120] + "\n")

The output shows an interesting behavior: For every "project" that I open, output is created upon each cursor movement... until it suddenly stops after some messages (3, 10, 7, then 18, see below). Even though I continued to move the cursor, no new output was created until I opened a file in a different folder. I didn't try long enough, but probably elpy will soon start to crash again.

{"id":1,"method":"init","params":[{"backend":null,"project_root":"/home/daniel/uni/git/car900/dist/"}]}

{"id":2,"method":"get_calltip","params":["/home/daniel/uni/git/car900/dist/utils/music.py",{"filename":"/tmp/elpy-rpc-15 {"id":3,"method":"get_calltip","params":["/home/daniel/uni/git/car900/dist/utils/music.py",{"filename":"/tmp/elpy-rpc-15 {"id":1,"method":"init","params":[{"backend":null,"project_root":"/home/daniel/.emacs.d/elpa/elpy-20160131.118/"}]}

{"id":2,"method":"get_calltip","params":["/home/daniel/.emacs.d/elpa/elpy-20160131.118/elpy/main.py","\"\"\"Main int {"id":3,"method":"get_calltip","params":["/home/daniel/.emacs.d/elpa/elpy-20160131.118/elpy/main.py","\"\"\"Main int {"id":4,"method":"get_calltip","params":["/home/daniel/.emacs.d/elpa/elpy-20160131.118/elpy/main.py","\"\"\"Main int {"id":5,"method":"get_calltip","params":["/home/daniel/.emacs.d/elpa/elpy-20160131.118/elpy/main.py","\"\"\"Main int {"id":6,"method":"get_calltip","params":["/home/daniel/.emacs.d/elpa/elpy-20160131.118/elpy/main.py","\"\"\"Main int {"id":7,"method":"get_calltip","params":["/home/daniel/.emacs.d/elpa/elpy-20160131.118/elpy/main.py","\"\"\"Main int {"id":8,"method":"get_calltip","params":["/home/daniel/.emacs.d/elpa/elpy-20160131.118/elpy/main.py","\"\"\"Main int {"id":9,"method":"get_calltip","params":["/home/daniel/.emacs.d/elpa/elpy-20160131.118/elpy/main.py","\"\"\"Main int {"id":10,"method":"get_calltip","params":["/home/daniel/.emacs.d/elpa/elpy-20160131.118/elpy/main.py","\"\"\"Main in {"id":1,"method":"init","params":[{"backend":null,"project_root":"/home/daniel/git/advancedcaching/"}]}

{"id":2,"method":"get_calltip","params":["/home/daniel/git/advancedcaching/advancedcaching/core.py",{"filename":"/tmp/el {"id":3,"method":"get_calltip","params":["/home/daniel/git/advancedcaching/advancedcaching/core.py",{"filename":"/tmp/el {"id":4,"method":"get_calltip","params":["/home/daniel/git/advancedcaching/advancedcaching/core.py",{"filename":"/tmp/el {"id":5,"method":"get_calltip","params":["/home/daniel/git/advancedcaching/advancedcaching/core.py",{"filename":"/tmp/el {"id":6,"method":"get_calltip","params":["/home/daniel/git/advancedcaching/advancedcaching/core.py",{"filename":"/tmp/el {"id":7,"method":"get_calltip","params":["/home/daniel/git/advancedcaching/advancedcaching/core.py",{"filename":"/tmp/el {"id":1,"method":"init","params":[{"backend":null,"project_root":"/home/daniel/uni/git/caldav-client/"}]}

{"id":2,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-15383 {"id":3,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-15383 {"id":4,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-15383 {"id":5,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-15383 {"id":6,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-15383 {"id":7,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-15383 {"id":8,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-15383 {"id":9,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-15383 {"id":10,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-1538 {"id":11,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-1538 {"id":12,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-1538 {"id":13,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-1538 {"id":14,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-1538 {"id":15,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-1538 {"id":16,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-1538 {"id":17,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-1538 {"id":18,"method":"get_calltip","params":["/home/daniel/uni/git/caldav-client/server.py",{"filename":"/tmp/elpy-rpc-1538

jorgenschaefer commented 8 years ago

Hm. Can you add os.getpid() to the output, to check if that's a new process every time?

Also, does the following lock up after some time?

(let* ((buf (get-buffer-create "*Elpy Test*"))
       (process-connection-type nil)
       (process-environment (elpy-rpc--environment))
       (proc (start-process "Elpy Test" buf "/bin/cat")))
  (display-buffer buf)
  (sit-for 0.1)
  (with-current-buffer buf
    (let ((n 0))
      (while t
        (process-send-string proc (format "Line %s\n" n))
        (setq n (+ n 1))
        (sit-for 0.01)))))
danielfett commented 8 years ago

Different "projects" yield different pids, yes. It looks like the longer the messages are, the earlier the crash happens (smells like a buffer running full).

The script above does not crash even after 8000 messages (added about 100 characters after Line %s to make the messages longer).

danielfett commented 8 years ago

I added the following code to read_json:

   line = ""
    with open('/tmp/elpy-debug-python-server.log', 'a') as f:
        f.write(str(os.getpid()))
        f.write(" ")
        while True:
            byte = self.stdin.read(1)
            f.write(byte)
            f.flush()
            line += byte
            if byte == "\n":
                break

replacing the line = ...readline() stuff.

The output of this does never break in the middle of a message (tried 4 times and with long JSON messages).

danielfett commented 8 years ago

Oh, but it also never stops with just the PID written to the file, meaning that elpy does not wait for new messages, but is occupied itself.

jorgenschaefer commented 8 years ago

Oh, but it also never stops with just the PID written to the file, meaning that elpy does not wait for new messages, but is occupied itself.

You're missing f.flush() to be certain of that, I think?

danielfett commented 8 years ago

Yes, that came to me just right now. With flush, the output ends after the pid. So the server IS waiting.

jorgenschaefer commented 8 years ago

Emacs is doing something very weird there. Does this reproduce the problem?

(with-temp-buffer
  (python-mode)
  (elpy-mode)
  (let ((n 0))
    (while t
      (message ">>> %S" (elpy-rpc "echo" (list n)))
      (setq n (+ 1 n))
      (sit-for 0.01))))
danielfett commented 8 years ago

Yes. Tried four times, crashed between message 518 and 1350.

danielfett commented 8 years ago

Sometimes in the middle of a message.

jorgenschaefer commented 8 years ago

Can you run strace -f on Emacs before running that, reproduce the problem, and post (or mail) the output?

danielfett commented 8 years ago

emacs-strace.zip

jorgenschaefer commented 8 years ago

Thank you! 26611 is Emacs, 26684 is Python, 26687 is some thread within Emacs I think.

[pid 26611] read(19,  <unfinished ...>
[pid 26611] <... read resumed> "{\"result\": [1065], \"id\": 1067}\n", 4096) = 31

This is the last time Emacs actually reads from fd 19. Shortly thereafter, it sends another request:

[pid 26611] write(18, "{\"id\":1068,\"method\":\"echo\",\"para"..., 44 <unfinished ...>
[pid 26687] <... open resumed> )        = -1 ENOENT (No such file or directory)
[pid 26611] <... write resumed> )       = 44
[pid 26684] <... read resumed> "{\"id\":1068,\"method\":\"echo\",\"para"..., 4096) = 44
[pid 26684] futex(0x1d6b6a0, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 26611] pselect6(20, [3 7 8 11 19], [], NULL, {1, 0}, {NULL, 8} <unfinished ...>

Here, Emacs sent the last JSON-RPC method call. Elpy responds a bit later:

[pid 26684] write(4, "{", 1)            = 1
[pid 26684] write(4, "\"", 1)           = 1
[pid 26684] write(4, "i", 1)            = 1
[pid 26684] write(4, "d", 1)            = 1
[pid 26684] write(4, "\"", 1)           = 1
[pid 26684] write(4, ":", 1)            = 1
[pid 26684] write(4, "1", 1)            = 1
[pid 26684] write(4, "0", 1 <unfinished ...>
[pid 26684] <... write resumed> )       = 1
[pid 26684] write(4, "6", 1)            = 1
[pid 26684] write(4, "8", 1 <unfinished ...>
[pid 26684] <... write resumed> )       = 1
[pid 26684] futex(0x1d6b6a0, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>

Then it hangs. The line is incomplete, but Python does not try to resume sending here. Actually, it does not do anything at all. It hangs.

I'm not even sure how it would do that, I mean Elpy is doing self.stdout.write(json.dumps(kwargs) + "\n") – it's not like it's doing anything in Pythen when emitting those things.

It would be interesting to see the Elpy backtrace. Could you see if you can get Python to produce a backtrace there? E.g. using https://stackoverflow.com/questions/132058/showing-the-stack-trace-from-a-running-python-application or similar methods?

Elpy should show the backtrace automatically. If not, it might be hiding in the *elpy-rpc...* buffers.

NoviceLive commented 8 years ago

(Hope this helps or I can get some help.)

Description

When elpy is enabled, Emacs hangs frequently, even in Shell-script mode. And, when elpy is disabled, no hang any more.

No process consumes significant CPU when Emacs hangs.

I think elpy interfered with company-mode, or my scheme of tweaking Emacs does something wrong.

Experiments

Setup

All used packages are cloned from their repositories (checking out master branch), and with no other preparation nor installation operation except adding the following lines in my ~/.emacs.d/init.el.

Elpy and its Emacs Lisp dependencies.

(add-to-list 'load-path "~/.emacs.d/vendor/company-mode/")
(require 'company)
(add-hook 'after-init-hook 'global-company-mode)

(add-to-list 'load-path "~/.emacs.d/vendor/pyvenv/")

(add-to-list 'load-path "~/.emacs.d/vendor/highlight-indentation/")

(add-to-list 'load-path "~/.emacs.d/vendor/yasnippet/")
(require 'yasnippet)
(yas-global-mode)

(add-to-list 'load-path "~/.emacs.d/vendor/elpy/")
(require 'elpy)
(elpy-enable)

Experiment 1 With Elpy Enabled

Say, keep the following lines in init.el.

(add-to-list 'load-path "~/.emacs.d/vendor/elpy/")
(require 'elpy)
(elpy-enable)

Experiment 2 With Elpy Disabled

Say, comment the following lines in init.el.

(add-to-list 'load-path "~/.emacs.d/vendor/elpy/")
(require 'elpy)
(elpy-enable)

Do the Following

Step 1. Open a non-existent shell script file (Yes, shell script), e.g. emacs test.sh.

Step 2. Enter /root (/ will activate path completion, you may try other paths like /foobar), and then C-a (a.k.a move-beginning-of-line), C-k (kill-line), C-x C-s (save-buffer). Step 3. Repeat Step 2 about 10 times or so.

My Results

With Elpy enabled, Emacs hangs frequently after typing /root, which leaves me no chance to continue.

I can C-ggg and continue experiments.

With Elpy disabled, no hang observed.

Other Observation

If Elpy is enabled, frequent hangs are observed when completing path in C-x C-f (find-file) and M-! (shell-command).

Emacs continues to hang even I checked out the 0.8.0 release of compay-mode, with other packages also checked out to the version specified in elpy/Cask.

toggle-debug-on-quit

Debugger entered--Lisp error: (quit)
  call-process("ssh" nil t nil "-o" "ControlPath=%C" "host.does.not.exist")
  (progn (call-process "ssh" nil t nil "-o" "ControlPath=%C" "host.does.not.exist") (goto-char (point-min)) (if (search-forward-regexp "unknown.+key" nil t) (setq result (concat result " -o ControlPath='tramp.%%r@%%h:%%p'")) (setq result (concat result " -o ControlPath='tramp.%%C'"))))
  (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlPath=%C" "host.does.not.exist") (goto-char (point-min)) (if (search-forward-regexp "unknown.+key" nil t) (setq result (concat result " -o ControlPath='tramp.%%r@%%h:%%p'")) (setq result (concat result " -o ControlPath='tramp.%%C'")))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlPath=%C" "host.does.not.exist") (goto-char (point-min)) (if (search-forward-regexp "unknown.+key" nil t) (setq result (concat result " -o ControlPath='tramp.%%r@%%h:%%p'")) (setq result (concat result " -o ControlPath='tramp.%%C'")))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
  (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlPath=%C" "host.does.not.exist") (goto-char (point-min)) (if (search-forward-regexp "unknown.+key" nil t) (setq result (concat result " -o ControlPath='tramp.%%r@%%h:%%p'")) (setq result (concat result " -o ControlPath='tramp.%%C'")))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
  (if (zerop (length result)) nil (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlPath=%C" "host.does.not.exist") (goto-char (point-min)) (if (search-forward-regexp "unknown.+key" nil t) (setq result (concat result " -o ControlPath='tramp.%%r@%%h:%%p'")) (setq result (concat result " -o ControlPath='tramp.%%C'")))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlPersist") (goto-char (point-min)) (if (search-forward-regexp "missing.+argument" nil t) (progn (setq result ...)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))
  (progn (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlMaster") (goto-char (point-min)) (if (search-forward-regexp "missing.+argument" nil t) (progn (setq result "-o ControlMaster=auto")))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (if (zerop (length result)) nil (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlPath=%C" "host.does.not.exist") (goto-char (point-min)) (if (search-forward-regexp "unknown.+key" nil t) (setq result ...) (setq result ...))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlPersist") (goto-char (point-min)) (if (search-forward-regexp "missing.+argument" nil t) (progn ...))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))))
  (if (executable-find "ssh") (progn (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlMaster") (goto-char (point-min)) (if (search-forward-regexp "missing.+argument" nil t) (progn ...))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (if (zerop (length result)) nil (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlPath=%C" "host.does.not.exist") (goto-char ...) (if ... ... ...)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlPersist") (goto-char ...) (if ... ...)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))))
  (progn (if (executable-find "ssh") (progn (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process "ssh" nil t nil "-o" "ControlMaster") (goto-char ...) (if ... ...)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (if (zerop (length result)) nil (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ... ... ...) (and ... ...)))) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ... ... ...) (and ... ...))))))))
  (condition-case nil (progn (if (executable-find "ssh") (progn (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ... ... ...) (and ... ...)))) (if (zerop (length result)) nil (let ((temp-buffer ...)) (save-current-buffer (set-buffer temp-buffer) (unwind-protect ... ...))) (let ((temp-buffer ...)) (save-current-buffer (set-buffer temp-buffer) (unwind-protect ... ...))))))) (error nil))
  (let ((result "") (case-fold-search t)) (condition-case nil (progn (if (executable-find "ssh") (progn (let ((temp-buffer ...)) (save-current-buffer (set-buffer temp-buffer) (unwind-protect ... ...))) (if (zerop (length result)) nil (let (...) (save-current-buffer ... ...)) (let (...) (save-current-buffer ... ...)))))) (error nil)) result)
  (defvar tramp-ssh-controlmaster-options (let ((result "") (case-fold-search t)) (condition-case nil (progn (if (executable-find "ssh") (progn (let (...) (save-current-buffer ... ...)) (if (zerop ...) nil (let ... ...) (let ... ...))))) (error nil)) result) "Call ssh to detect whether it supports the Control* arguments.\nReturn a string to be used in `tramp-methods'.")
  eval-buffer(#<buffer  *load*> nil "/usr/share/emacs/24.5/lisp/net/tramp-loaddefs.el" nil t)  ; Reading at buffer position 7082
  load-with-code-conversion("/usr/share/emacs/24.5/lisp/net/tramp-loaddefs.el" "/usr/share/emacs/24.5/lisp/net/tramp-loaddefs.el" nil t)
  require(tramp-loaddefs)
  byte-code("\300\301!\207" [require tramp-loaddefs] 2)
  byte-code("\300\301\302\303#\210\300\304\305\306#\210\300\304\307\306#\210\300\304\310\306#\210\300\304\311\306#\210\300\304\312\306#\210\300\304\313\306#\210\300\314\315\316#\210\300\317\320\316#\210\300\304\321\306#\210\300\322\323\306#\210\300\324\325\306#\210\300\322\326\306#\210\300\327\330\316#\210\300\331\332\303#\210\300\331\333\303#\210\300\331\334\303#\210\300\331\335\303#\210\300\331\336\303#\210\300\337\340\341#\210\342\343!\203\206^@\344\345\343\"\210\202\215^@\344\345\346\347B\"\210\342\350!\203\233^@\344\351\350\"\210\202\256^@\344\351\346\352B\"\210\353\351\354\355#\210\353\351\356\306#\210\300\207" [byte-code "\300\301!?\205^P^@\302\303\304\"\210\302\305\304\"\207" [fboundp ignore-errors load "cl" noerror "cl-macs"] 3 "\300\301!\207" [require advice] 2 [require custom] [require format-spec] [require shell] [require trampver] [require tramp-loaddefs] "\300\301\302\303#\206^M^@\300\304\302\303#\207" [require password-cache nil noerror password] 4 "\300\301\302\303#\207" [require auth-source nil noerror] [require timer] "\300\301!?\205\n^@\302\303!\207" [boundp last-coding-system-used (lambda (def-tmp-var) (defvar last-coding-system-used def-tmp-var)) nil] "\302\303!\205^S^@\304\305!\210\303^P\306\305!\210\307\211^Q\207" [byte-compile-not-obsolete-var byte-compile-not-obsolete-vars boundp directory-sep-char (lambda (def-tmp-var) (defvar byte-compile-not-obsolete-var def-tmp-var)) nil (lambda (def-tmp-var) (defvar byte-compile-not-obsolete-vars def-tmp-var)) (directory-sep-char)] [boundp remote-file-name-inhibit-cache (lambda (def-tmp-var) (defvar remote-file-name-inhibit-cache def-tmp-var)) nil] "\300\301\302\303B\"\207" [defalias tramp-compat-funcall macro #[(function &rest arguments) "\302\303\304^HD\305^HDE\306\307^H   BBDE\207" [function arguments when or subrp functionp with-no-warnings funcall] 6]] "\300\301!?\205^K^@\302\301\303\"\207" [fboundp set-buffer-multibyte defalias ignore] [fboundp file-remote-p defalias #[(file &optional identification connected) "\303^H!\205^X^@\304\305!\204^R^@\306\305!\205^X^@\305\307^H  \n$\207" [file identification connected tramp-tramp-file-p subrp tramp-file-name-handler functionp file-remote-p] 5]] [fboundp process-file defalias #[(program &optional infile buffer display &rest args) "\306^H!\205^P^@\307\310\311    \n^K\f^M&^G\207" [default-directory program infile buffer display args tramp-tramp-file-p apply tramp-file-name-handler process-file] 8]] [fboundp start-file-process defalias #[(name buffer program &rest program-args) "\305^H!\205^O^@\306\307\310  \n^K\f&^F\207" [default-directory name buffer program program-args tramp-tramp-file-p apply tramp-file-name-handler start-file-process] 7]] [fboundp set-file-times defalias #[(filename &optional time) "\302^H!\205^W^@\303\304!\204^R^@\305\304!\205^W^@\304\306^H   #\207" [filename time tramp-tramp-file-p subrp tramp-file-name-handler functionp set-file-times] 4]] "\300\301\302\"?\205^X^@\303\304\305\306\307$\210\310\304\307\"\210\311\312\313\"\207" [featurep files remote-wildcards ad-add-advice file-expand-wildcards (tramp-advice-file-expand-wildcards nil t (advice lambda nil (let ((name (ad-get-arg 0))) (if (and (tramp-tramp-file-p name) (not ...)) (setq ad-return-value (list name)) ad-do-it)))) around nil ad-activate add-hook tramp-unload-hook #[nil "\300\301\302\303#\210\304\301!\207" [ad-remove-advice file-expand-wildcards around tramp-advice-file-expand-wildcards ad-activate] 4]] 5 fboundp with-temp-message defalias tramp-compat-with-temp-message macro #[(_message &rest body) "\301^HB\207" [body progn] 2 "Display MESSAGE temporarily if non-nil while BODY is evaluated."] condition-case-unless-debug tramp-compat-condition-case-unless-debug #[(var bodyform &rest handlers) "\304\305!^X\306^H\307\310  EDC\311\312\313^HD\314\n\313^HD^KBBBFE)\207" [bodysym bodyform var handlers make-symbol "body" let lambda nil if debug-on-error funcall condition-case] 9 "Like `condition-case' except that it does not catch anything when debugging."] put edebug-form-spec condition-case lisp-indent-function] 4)
  require(tramp-compat)
  byte-code("\300\301!\210\302\303\304\305\306\307\306\310\311\312& \210\313\314\315\316\306\303\317\320&^G\210\313\321\322\323\306\303\317\324&^G\210\325\326\327\330#\210\313\331\304\332\306\303\317\333&^G\210\313\334\335\336\306\303\317\337&^G\210\313\340\341\342\306\303\317\343&^G\210\313\344\345\346\311\347\306\303\317\350&   \207" [require tramp-compat custom-declare-group tramp nil "Edit remote files with a combination of ssh, scp, etc." :group files comm :version "22.1" custom-declare-variable tramp-mode t "Whether Tramp is enabled.\nIf it is set to nil, all remote file names are used literally." :type boolean tramp-verbose 3 "Verbosity level for Tramp messages.\nAny level x includes messages for all levels 1 .. x-1.  The levels are\n\n 0  silent (no tramp messages at all)\n 1  errors\n 2  warnings\n 3  connection to remote hosts (default level)\n 4  activities\n 5  internal\n 6  sent and received strings\n 7  file caching\n 8  connection properties\n 9  test commands\n10  traces (huge)." integer byte-code "\300\301!\205^P^@\302\303\304\305\306\307\310\311&^G\207" [boundp backup-directory-alist custom-declare-variable tramp-backup-directory-alist nil "Alist of filename patterns and backup directory names.\nEach element looks like (REGEXP . DIRECTORY), with the same meaning like\nin `backup-directory-alist'.  If a Tramp file is backed up, and DIRECTORY\nis a local file name, the backup directory is prepended with Tramp file\nname prefix (method, user, host) of file.\n\n(setq tramp-backup-directory-alist backup-directory-alist)\n\ngives the same backup policy for Tramp files on their hosts like the\npolicy for local files." :group tramp :type (repeat (cons (regexp :tag "Regexp matching filename") (directory :tag "Backup directory name")))] 8 tramp-auto-save-directory "Put auto-save files in this directory, if set.\nThe idea is to use a local directory so that auto-saving is faster." (choice (const nil) string) tramp-encoding-shell (if (memq system-type (quote (windows-nt))) (getenv "COMSPEC") "/bin/sh") "Use this program for encoding and decoding commands on the local host.\nThis shell is used to execute the encoding and decoding command on the\nlocal host, so if you want to use `~' in those commands, you should\nchoose a shell here which groks tilde expansion.  `/bin/sh' normally\ndoes not understand tilde expansion.\n\nFor encoding and decoding, commands like the following are executed:\n\n    /bin/sh -c COMMAND < INPUT > OUTPUT\n\nThis variable can be used to change the \"/bin/sh\" part.  See the\nvariable `tramp-encoding-command-switch' for the \"-c\" part.\n\nIf the shell must be forced to be interactive, see\n`tramp-encoding-command-interactive'.\n\nNote that this variable is not used for remote commands.  There are\nmechanisms in tramp.el which automatically determine the right shell to\nuse for the remote host." (file :must-match t) tramp-encoding-command-switch (if (string-match "cmd\\.exe" tramp-encoding-shell) "/c" "-c") "Use this switch together with `tramp-encoding-shell' for local commands.\nSee the variable `tramp-encoding-shell' for more information." string tramp-encoding-command-interactive (unless (string-match "cmd\\.exe" tramp-encoding-shell) "-i") "Use this switch together with `tramp-encoding-shell' for interactive shells.\nSee the variable `tramp-encoding-shell' for more information." "24.1" (choice (const nil) string)] 10)
  tramp-completion-handle-file-name-completion("et" "/" file-exists-p)
  apply(tramp-completion-handle-file-name-completion ("et" "/" file-exists-p))
  (progn (apply (cdr fn) args))
  (unwind-protect (progn (apply (cdr fn) args)) (set-match-data save-match-data-internal (quote evaporate)))
  (let ((save-match-data-internal (match-data))) (unwind-protect (progn (apply (cdr fn) args)) (set-match-data save-match-data-internal (quote evaporate))))
  (if (and fn tramp-mode (or (eq tramp-syntax (quote sep)) (featurep (quote tramp)) (and (boundp (quote partial-completion-mode)) (symbol-value (quote partial-completion-mode))) (featurep (quote ido)) (featurep (quote icicles)))) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (apply (cdr fn) args)) (set-match-data save-match-data-internal (quote evaporate)))) (tramp-completion-run-real-handler operation args))
  (let ((directory-sep-char 47) (fn (assoc operation tramp-completion-file-name-handler-alist))) (if (and fn tramp-mode (or (eq tramp-syntax (quote sep)) (featurep (quote tramp)) (and (boundp (quote partial-completion-mode)) (symbol-value (quote partial-completion-mode))) (featurep (quote ido)) (featurep (quote icicles)))) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (apply (cdr fn) args)) (set-match-data save-match-data-internal (quote evaporate)))) (tramp-completion-run-real-handler operation args)))
  tramp-completion-file-name-handler(file-name-completion "et" "/" file-exists-p)
  file-name-completion("et" "/" file-exists-p)
  #[0 "\302\305=\203^H^@\306\207\307\300\310\311^[\312^C^C^C#)\266\203\203'^@\313\314\315\316\317 \"\300\320\310O\301\302%\207\302\242\321=\203I^@\322\300!G\323\302A\310\311^[\312^C^C^C#)\266\203\321^B\300G^^BBB\207\302\324=\203_^@\325\300G!?\205\310^@\301\206\\^@\326\300!\207\327\300!\322\300!\211\206j^@\f\302\204\204^@\330^C^B\301#\211;\203~^@^B^AP\202^?^@\211\262^A\202\306^@\302\311=\205\306^@\331^C^B\"\301\332>\204\303^@\310\301\333=\203\237^@\334\202\240^@\301\335^D!^\^B\211\203\275^@\211@^B^A!\203\266^@\211^DB\262^D^AA\266\202\202\245^@\210)^A\237\266\203\211\262^A\266\203\207" ["/et" file-exists-p nil inhibit-changing-match-data default-directory metadata (metadata (category . file)) "\\`~[^/\\]*\\'" nil t string-match completion-table-with-context "~" mapcar #[257 "\211\300P\207" ["/"] 3 "\n\n(fn U)"] system-users 1 boundaries file-name-directory "/" lambda zerop file-exists-p file-name-nondirectory file-name-completion file-name-all-completions (nil file-exists-p) file-directory-p #[257 "\211G\211\300V\205^N^@^A^ASH\301=\207" [0 47] 4 "\n\n(fn S)"] expand-file-name] 10 "\n\n(fn)"]()
  funcall(#[0 "\302\305=\203^H^@\306\207\307\300\310\311^[\312^C^C^C#)\266\203\203'^@\313\314\315\316\317 \"\300\320\310O\301\302%\207\302\242\321=\203I^@\322\300!G\323\302A\310\311^[\312^C^C^C#)\266\203\321^B\300G^^BBB\207\302\324=\203_^@\325\300G!?\205\310^@\301\206\\^@\326\300!\207\327\300!\322\300!\211\206j^@\f\302\204\204^@\330^C^B\301#\211;\203~^@^B^AP\202^?^@\211\262^A\202\306^@\302\311=\205\306^@\331^C^B\"\301\332>\204\303^@\310\301\333=\203\237^@\334\202\240^@\301\335^D!^\^B\211\203\275^@\211@^B^A!\203\266^@\211^DB\262^D^AA\266\202\202\245^@\210)^A\237\266\203\211\262^A\266\203\207" ["/et" file-exists-p nil inhibit-changing-match-data default-directory metadata (metadata (category . file)) "\\`~[^/\\]*\\'" nil t string-match completion-table-with-context "~" mapcar #[257 "\211\300P\207" ["/"] 3 "\n\n(fn U)"] system-users 1 boundaries file-name-directory "/" lambda zerop file-exists-p file-name-nondirectory file-name-completion file-name-all-completions (nil file-exists-p) file-directory-p #[257 "\211G\211\300V\205^N^@^A^ASH\301=\207" [0 47] 4 "\n\n(fn S)"] expand-file-name] 10 "\n\n(fn)"])
  completion-file-name-table("/et" file-exists-p nil)
  try-completion("/et" completion-file-name-table file-exists-p)
  completion-basic-try-completion("/et" completion-file-name-table file-exists-p 3)
  #[257 "\300^A^M\2368\301\242\302\242\303\304\242$\207" [1 ("/et") (completion-file-name-table) file-exists-p (3) completion-styles-alist] 6 "\n\n(fn STYLE)"](basic)
  #[0 "\302\300\301\242\301\211\242A\240\210\242!\240\207" [#[257 "\300^A^M\2368\301\242\302\242\303\304\242$\207" [1 ("/et") (completion-file-name-table) file-exists-p (3) completion-styles-alist] 6 "\n\n(fn STYLE)"] ((partial-completion emacs22)) (nil)] 5 "\n\n(fn)"]()
  funcall(#[0 "\302\300\301\242\301\211\242A\240\210\242!\240\207" [#[257 "\300^A^M\2368\301\242\302\242\303\304\242$\207" [1 ("/et") (completion-file-name-table) file-exists-p (3) completion-styles-alist] 6 "\n\n(fn STYLE)"] ((partial-completion emacs22)) (nil)] 5 "\n\n(fn)"])
  completion--some(#[257 "\300^A^M\2368\301\242\302\242\303\304\242$\207" [1 ("/et") (completion-file-name-table) file-exists-p (3) completion-styles-alist] 6 "\n\n(fn STYLE)"] (basic partial-completion emacs22))
  completion--nth-completion(1 "~//et" read-file-name-internal file-exists-p 5 (metadata (category . file) (completion--unquote-requote . t)))
  completion-try-completion("~//et" read-file-name-internal file-exists-p 5 (metadata (category . file) (completion--unquote-requote . t)))
  completion--do-completion(12 17)
  completion--in-region-1(12 17)
  #[1028 "^A^A^X^Y\n\203!^@\304^D!\203^R^@^C\202^U^@\305^D!\305^D\306\"^C^CF^S\307\310!\210\311^D^D\"*\207" [minibuffer-completion-predicate minibuffer-completion-table completion-in-region-mode-predicate completion-in-region--data markerp copy-marker t completion-in-region-mode 1 completion--in-region-1] 8 "\n\n(fn START END COLLECTION PREDICATE)"](12 17 read-file-name-internal file-exists-p)
  apply(#[1028 "^A^A^X^Y\n\203!^@\304^D!\203^R^@^C\202^U^@\305^D!\305^D\306\"^C^CF^S\307\310!\210\311^D^D\"*\207" [minibuffer-completion-predicate minibuffer-completion-table completion-in-region-mode-predicate completion-in-region--data markerp copy-marker t completion-in-region-mode 1 completion--in-region-1] 8 "\n\n(fn START END COLLECTION PREDICATE)"] (12 17 read-file-name-internal file-exists-p))
  #[771 "^B:\2030^@^B@\301=\203^W^@\300\242\302^C^EA\"\303^C#\207\304^C@\305\306\307\310\311\312\300!\313\"\314\315%^F^FA^F^F#^C#\207\304\316^B\"\207" [(#0) t append nil apply apply-partially make-byte-code 642 "\300\242^C^C^C#\207" vconcat vector [] 7 "\n\n(fn FUNS GLOBAL &rest ARGS)" #[1028 "^A^A^X^Y\n\203!^@\304^D!\203^R^@^C\202^U^@\305^D!\305^D\306\"^C^CF^S\307\310!\210\311^D^D\"*\207" [minibuffer-completion-predicate minibuffer-completion-table completion-in-region-mode-predicate completion-in-region--data markerp copy-marker t completion-in-region-mode 1 completion--in-region-1] 8 "\n\n(fn START END COLLECTION PREDICATE)"]] 12 "\n\n(fn FUNS GLOBAL ARGS)"](nil nil (12 17 read-file-name-internal file-exists-p))
  completion--in-region(12 17 read-file-name-internal file-exists-p)
  completion-in-region(12 17 read-file-name-internal file-exists-p)
  minibuffer-complete()
  call-interactively(minibuffer-complete nil nil)
  command-execute(minibuffer-complete)
  read-from-minibuffer("Find file: " "~/" (keymap (keymap (32)) keymap (10 . minibuffer-complete-and-exit) (13 . minibuffer-complete-and-exit) keymap (menu-bar keymap (minibuf "Minibuf" keymap (tab menu-item "Complete" minibuffer-complete :help "Complete as far as possible") (space menu-item "Complete Word" minibuffer-complete-word :help "Complete at most one word") (63 menu-item "List Completions" minibuffer-completion-help :help "Display all possible completions") "Minibuf")) (27 keymap (118 . switch-to-completions)) (prior . switch-to-completions) (63 . minibuffer-completion-help) (32 . minibuffer-complete-word) (9 . minibuffer-complete) keymap (menu-bar keymap (minibuf "Minibuf" keymap (previous menu-item "Previous History Item" previous-history-element :help "Put previous minibuffer history element in the minibuffer") (next menu-item "Next History Item" next-history-element :help "Put next minibuffer history element in the minibuffer") (isearch-backward menu-item "Isearch History Backward" isearch-backward :help "Incrementally search minibuffer history backward") (isearch-forward menu-item "Isearch History Forward" isearch-forward :help "Incrementally search minibuffer history forward") (return menu-item "Enter" exit-minibuffer :key-sequence "^M" :help "Terminate input and exit minibuffer") (quit menu-item "Quit" abort-recursive-edit :help "Abort input and exit minibuffer") "Minibuf")) (10 . exit-minibuffer) (13 . exit-minibuffer) (7 . abort-recursive-edit) (C-tab . file-cache-minibuffer-complete) (9 . self-insert-command) (XF86Back . previous-history-element) (up . previous-history-element) (prior . previous-history-element) (XF86Forward . next-history-element) (down . next-history-element) (next . next-history-element) (27 keymap (114 . previous-matching-history-element) (115 . next-matching-history-element) (112 . previous-history-element) (110 . next-history-element))) nil file-name-history "~/" nil)
  completing-read-default("Find file: " read-file-name-internal file-exists-p confirm-after-completion "~/" file-name-history "~/" nil)
  completing-read("Find file: " read-file-name-internal file-exists-p confirm-after-completion "~/" file-name-history "~/")
  read-file-name-default("Find file: " nil "~/" confirm-after-completion nil nil)
  read-file-name("Find file: " nil "~/" confirm-after-completion)
  find-file-read-args("Find file: " confirm-after-completion)
  byte-code("\300\301\302 \"\207" [find-file-read-args "Find file: " confirm-nonexistent-file-or-buffer] 3)
  call-interactively(find-file nil nil)
  command-execute(find-file)

strace

sudo strace -fp27142                                                          [3/1943]
strace: Process 27142 attached with 4 threads
[pid 27145] restart_syscall(<... resuming interrupted poll ...> <unfinished ...>
[pid 27144] restart_syscall(<... resuming interrupted poll ...> <unfinished ...>
[pid 27143] restart_syscall(<... resuming interrupted poll ...> <unfinished ...>
[pid 27142] read(18, 0x7ffe1d4ffdf8, 16312) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
[pid 27142] --- SIGIO {si_signo=SIGIO, si_code=SI_KERNEL} ---
[pid 27142] rt_sigreturn({mask=[]})     = -1 EINTR (Interrupted system call)
[pid 27142] recvmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{"U\2\0100\0054$\1\3\30\10\0\20\0\0\0\0\0\0\30\30\30\30\30\0\0\3\37@\2\0\0", 4096}], msg_contro$len=0, msg_flags=0}, 0) = 32
[pid 27142] recvmsg(5, 0x7ffe1d4ff030, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27142] poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27142] poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27142] recvmsg(5, 0x7ffe1d4ff030, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27142] poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27142] read(18, 0x7ffe1d4ffdf8, 16312) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
[pid 27142] --- SIGIO {si_signo=SIGIO, si_code=SI_KERNEL} ---
[pid 27142] rt_sigreturn({mask=[]})     = -1 EINTR (Interrupted system call)
[pid 27142] recvmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{"U\2\0100\2575$\1\3\20\0\0\20\0\0\0\0\0\0\20\20\20\20\20\0\0\3\37@\3\0\0", 4096}], msg_control$en=0, msg_flags=0}, 0) = 32
[pid 27142] recvmsg(5, 0x7ffe1d4ff030, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27142] poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27142] poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27142] recvmsg(5, 0x7ffe1d4ff030, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27142] poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27142] read(18, 0x7ffe1d4ffdf8, 16312) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
[pid 27142] --- SIGIO {si_signo=SIGIO, si_code=SI_KERNEL} ---
[pid 27142] rt_sigreturn({mask=[]})     = -1 EINTR (Interrupted system call)
[pid 27142] recvmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{"U\2\0100yp$\1\3\24\4\0\20\0\0\0\0\0\0\24\24\24\24\24\0\0\3\37%\2\0\0", 4096}], msg_controllen$
0, msg_flags=0}, 0) = 32
[pid 27142] recvmsg(5, 0x7ffe1d4ff030, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27142] poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27142] poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27142] recvmsg(5, 0x7ffe1d4ff030, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 27142] poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN}], 4, 0) = 0 (Timeout)
[pid 27142] read(18, ^Cstrace: Process 27142 detached
 <detached ...>
strace: Process 27143 detached
strace: Process 27144 detached
strace: Process 27145 detached

Version Information

emacs --version
GNU Emacs 24.5.1
Copyright (C) 2015 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
jorgenschaefer commented 8 years ago

@NoviceLive, that is some excellent report and debugging, thank you!

The problem you encounter is that find-file tries to run tramp, and tramp then tries to ssh to some unknown host, which hangs Emacs. (I personally hate tramp with a passion because it rarely works well for me and most of the time just breaks, like in this case, so I disabled it completely, but that might not be an option for everyone)

Elpy does not actually do anything with tramp, so I am a bit confused why that would happen.

Can you try and (setq elpy-modules nil) before (elpy-enable) and see if the problem persists? If yes, can you try to replace all of the Elpy configuration with the following and see if one of them is the culprit?

(require 'cus-edit)
(require 'etags)
(require 'files-x)
(require 'grep)
(require 'ido)
(require 'json)
(require 'python)
NoviceLive commented 8 years ago

Thanks for pointing it out. Let me see. (I just started learning Emacs Lisp.)

NoviceLive commented 8 years ago

(setq elpy-modules nil) before (elpy-enable): Emacs hangs as usual.

Comment (require 'ido) will not hang!

(require 'cus-edit)
(require 'etags)
(require 'files-x)
(require 'grep)
(require 'ido)
(require 'json)
(require 'python)
jorgenschaefer commented 8 years ago

Huh. Looks like even just loading ido is hooking up tramp somehow, which gives you a broken file-finding history. This sounds like a bug to me.

If you replace the whole Elpy stuff with just (require 'ido) and that hangs Emacs, I think you can M-x report-emacs-bug :-(

NoviceLive commented 8 years ago

Well, that hangs Emacs. :(

jorgenschaefer commented 8 years ago

Heh. I think you have a bit more of a problem there than Elpy, I'm afraid. :-(

NoviceLive commented 8 years ago

Yeah, for the time being, I'd better wait for a new release of Emacs and learn hard. Thanks for the information.

jorgenschaefer commented 8 years ago

Good luck!

Nicholas-Autio-Mitchell commented 7 years ago

@jorgenschaefer I am getting this issue on Emacs 25.3.2, Ubuntu 16.04. Things get sluggish and my laptop started breathing heavily. htop shows it is the elpy process taking 100% of one of my cores and (after some waiting around) never coming out of that loop. Using elpy-restart-rpc gets things back to normal, but it happens again a few minutes later.

I had been working most the day and didn't change anything in my config when this started happening... however - I noticed something strange. I was in customize-group ENT elpy. I saw the option Show Value Elpy Profile Visualizer... I clicked on it and, well, it disappeared! After that, the menu-bar buttons were not working either! If I click on e.g. YASnippet, I just see and empty grey box appear. If I hit f10 to cycle through the menu-bar items, I get the functionality back. But this behaviour then continues. I have tried logging out and back in, as well as simply restarting emacs/elpy/python process etc - didn't help.

Could these things be related? Both symptoms of something else?

jorgenschaefer commented 7 years ago

Hello, and thanks for the report. Can you post the output of M-x elpy-config? Does the problem go away when you uninstall importmagic?

As for the second problem, I have no idea I'm afraid :-(

Nicholas-Autio-Mitchell commented 7 years ago

Here is the elpy-config output:

Virtualenv........: env-name (/home/user/anaconda3/envs/env-name)
RPC Python........: 3.5.2 (/home/user/anaconda3/envs/env-name/bin/python3)
Interactive Python: ipython (/home/user/anaconda3/envs/env-name/bin/ipython)
Emacs.............: 25.3.2
Elpy..............: 1.16.1
Jedi..............: 0.10.2 (0.11.0 available)
Rope..............: Not found (0.10.7 available)
Importmagic.......: 0.1.7
Autopep8..........: 1.3.3
Yapf..............: Not found (0.19.0 available)
Syntax checker....: Not found (flake8 --ignore=F403,F405,E266 --man-line-width 100)

There is a newer version of Jedi available.

[run] python3 -m pip install --upgrade jedi

The yapf package is not available. Commands using this will not work.

[run] python3 -m pip install yapf

The configured syntax checker could not be found. Elpy uses this
program to provide syntax checks of your programs, so you might want
to install one. Elpy by default uses flake8.

[run] python3 -m pip install flake8

Which doesn't make sense for flake8 or importmagic as they are both installed, in both the environment as well as site site-packages of Anaconda. You can notice that I set the WORKON variable to the anaconda environments and not virtualenv, which works great. Can't imagine that is causing the menu-bar issue.

The hanging, I thought, might be something to do with me using ipython as the interpreter, but that has also been working today without any issue. I think there may be a bug there when loops are sent. If I run e.g.

for i in range(1000):
    do_something(args, i)

... then either cancel the loop or not, I believe there is some broken link between elpy, ipython and python, which leaves the loop running. This is the only explanation I have right now.

jorgenschaefer commented 7 years ago

Is the flake8 command available for Emacs? That's what elpy looks for.

Does the hanging go away if you uninstall importmagic?

Nicholas-Autio-Mitchell commented 7 years ago

It works in Emacs with a simple command and a more extravagent one.

If I just run python-check and pass the string flake8 file.py --> it works If I run python-check and pass flake8 --ignore=E266,E501 --max-line-length=100 file.py --> it works

I have actually fixed my problem by using flycheck, which allows me to specify the flake8 config file setting the variable flycheck-flake8rc.

I still don't know for sure if this issue is linked to the hanging processes or not. I haven't had a hanging elpy/python process since I configured things using flycheck. But that was only yesterday ;)

Nicholas-Autio-Mitchell commented 7 years ago

@jorgenschaefer

The hanging issue is still occuring. I took a screenshot of the process shown in Terminal's htop:

elpy-hanging You can see if is the elpy.__main__ file that is stuck.

It seems to happen after I have had the error: Company: backend elpy-company-backend async timeout with args (candidates so)

I did once try to increase the time Company is allowed to find completions, but that didn't help. Turning of company by deactivating global-company-mode did not help, but executing elpy-rpc-restart did.

Another update:

I updated all packages in Emacs and things seem to be running a little smoother. Interestingly, I got this output in the buffer *Elpy Output*, after about 15 minutes of use:

Output from Backend

There was some unexpected output from the Elpy backend. This is usually some module that does not use correct logging, but might indicate a configuration problem.

Output /home/n1k31t4/anaconda3/envs/env-name/bin/python3: Error while finding spec for 'elpy.main' (ImportError: No module named 'elpy')

jorgenschaefer commented 7 years ago

Elpy uses a bunch of libraries. In that case, it should use jedi. That seems to be stuck in some kind of loop, apparently? Try upgrading Jedi?