-
-
Notifications
You must be signed in to change notification settings - Fork 245
High CPU load when bpython is in use #806
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
Comments
Hm do you have a particularly large number libraries installed? bpython walks through installed packages at startup in order to provide import completion, and it could be that it's taking a long time to do this properly, or it could be that there's an issue where this is taking longer for some other reason. |
Experiencing a similar problem on Fedora 32, package installed through DNF. If I start it from a near-blank venv, the CPU usage is normalized, but running |
Helpful to hear about the difference between venv and system-installed libs. My guess is still the import discovery code, I'd love to know what all those system calls are. |
I've looked into the systems calls that bpython is making, and found something quite curious...
For some reason, bpython is looking through my entire home folder recursively, and then gets into an infinite loop due to a symlink pointing to the root of my file system... If I start |
It indeed has to be related to import discovery though I don't think it should do that before even trying an import @thomasballinger ? |
I think we do, in |
@vista- what bpython is doing worming its way through cwd and all subdirectories (hopefully not all) is looking for python modules that could be imported. If it's checking places that aren't on the import path or couldn't possibly be imported, then that's a bug. It should only be necessary to check a subdirectories of a directory if the directory has a |
Not following symlinks would be a pretty easy thing to do (we could theoretically make it a setting if some people want to) or we could see if we cycle in the paths and stop there? |
Unfortunately, I'm a python beginner and am not too sure how I can validate whether bpython is checking places on the import path. As I understand, I have Maybe @vista- may provide better information on this. |
We might need to handle mount points too. But handling symlinks as a start would definitely help. I'll see if I can come up with something. |
I found that if I run bpython in a blank directory, it does not cause high cpu, and if I run bpython in my HOME dir, it causes high cpu. In Macbook, I use tool dtruss to track the bpython pid when cpu is 99%, I found bpython is scanning my home dir which has many files. In my case, I think that some symlinks in node_modules cause a infinite loop, because the high cpu happend only if node_modules is in the subdirectories of current dir that I run bpython. log: |
@pyang30 interesting! Based on those repeated filenames I'm guessing there are symlinks in there, so this the fix being worked on should address this. I'm surprised that the search goes into these in the first place though, I wonder why they look like Python packages. Are there init.py files in these folders? |
@thomasballinger no init.py or init.py file in these folders |
Thanks, I must not quite understand how this search works. |
Use os.path.realpath while crawling the filesystem for import completion make sure that we are not in a loop. Resolves #806
Experiencing a high python process CPU load despite not running any python script.
The issue persists as long as bpython is in use, quitting bpython resolves the high CPU load.
Running python or ipython does not cause the same issue.
MacOS Catalina 10.15.4
python 3.7.7: /Users/username/opt/anaconda3/bin/python
bpython 0.19
Apologies in advance if this issue has been addressed or the solution is trivial.
Thanks!
The text was updated successfully, but these errors were encountered: