Eclipse PyDev completion hangs (yet again)

戏子无情 提交于 2019-12-09 16:45:26

问题


I'm using PyDev in Eclipse as my Python editor. It's fine in terms of feature set. Everything works fine except for one very annoying thing:

Code completion itself works fast. When I press Alt+Space, the window pops out almost instantly and all the options are there. The option at the top is selected. Then comes the trouble. The detailed description won't appear until about 5-10 seconds. All this time CPU is working at maximum load and the interface is not responding. All the processor is consumed by the Eclipse Java process (the spawned Python process seems idle). Then a yellow window pops up, and all it contains is just a Python code of a selected function/variable. All consecutive details are displayed instantly. The procedure repeats when I close the completion window (for example by accepting one of the options and asking for completion again). This drives me crazy.

I've tried so far:

  • creating a whole new workspace,
  • creating an Eclipse/PyDev project from scratch,
  • tweaking JVM to make sure it has loads of memory,
  • making sure the right JVM is chosen (the latest Oracle JVM available),
  • making sure Python process communicates freely with the Java instance (I read about possible problems with that, but it seems not to be the issue).
  • making sure all the installed plugins are up to date.

The version I use is Eclipse Helios, because the last time I checked certain extensions weren't yet ported to the latest one.

Has anyone observed a similar issue? Was anyone able to get around it? General ideas on how to debug it and file a sensible bug report possibly? Other things worth checking for.

Any workaround less drastic than turning completion off completly?

Thanks!

EDIT:

I've also noticed a problem with a similar popup window in HTML/CSS editor. It looked somewhat similar (a yellow window, with some text inside) and it also took ages to display. Don't really know if that is related, but could be.

EDIT(2):

Ok, No I've started with a fresh install of the newest Eclipse Indigo, without any additional plugins apart from PyDev and the issue remains. Seems like I'll have to look for a new IDE.


回答1:


What version of Java are you using?

If you are on Windows 7, later versions of Java (I think 6+) will default to IPv6. This is probably causing the problem as Python maybe wanting IPv4.

Anyway, since I had this problem I tried disabling

  • PyLint
  • Code Analysis

but it was still hanging.

Pal's answer about "ipv4 utilization" triggered my memory about another problem I had solved by "preferring" IPv4.

See http://docs.oracle.com/javase/1.4.2/docs/guide/net/ipv6_guide/

What you want to do is to edit your eclipse.ini and add "-Djava.net.preferIPv4Stack=true" in the vmargs section

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
...
-vmargs
-...
-Djava.net.preferIPv4Stack=true
...

I no longer get hangs.




回答2:


Is there any chance you can provide the code that's making that happen (and add it to a bug report see: http://pydev.org/about.html for links)?

I use PyDev daily with some very large projects and don't have that problem, so, it may be some specific construct or scenario in your code -- or maybe you just haven't given Eclipse enough memory (which would make the garbage collector work much more), in which case, take a look at: What are the best JVM settings for Eclipse? (in specific, raise your -Xmx flag, although you can probably use the other tips there too).

If you can't provide a reproducible scenario, the other choice would be getting a profiler (i.e.: YourKit java profiler has a 15 days free which would help in this case), running that use-case in the profiler and passing a snapshot of what's happening in this situation (if that's the case, please open a bug report at pydev.org and I can help you there).




回答3:


I got this from pydev.org FAQs and it works fine for me.

When I do a code-completion, PyDev hangs, what can I do?

PyDev does most of its things in the java side, but some information can only be gotten from the python side (mainly builtins), so, in order to get that info, PyDev creates a shell and communicates with it through sockets.

The main problems when that happens are:

  1. There's a firewall blocking the communication to the shell

  2. In Linux, some kernels do not allow ipv4 utilization, which may make PyDev fail.

To enable it, do: echo 0 > /proc/sys/net/ipv6/bindv6only

  1. The timeout to connect is too smal.

It depends upon the "Timeout to connect to shell" in the code-completion preferences (window > preferences > PyDev > Code completion)

If nothing works, please report a bug (also, check if there is anything on the error log (window > show view > PDE Runtime > Error log) and on the eclipse '.log', which is located at the .metadata folder of the workspace location.



来源:https://stackoverflow.com/questions/7463691/eclipse-pydev-completion-hangs-yet-again

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!