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
Very slow traceback construction from Cython extension #1317
Comments
Installing pandas in my virtualenv seems to mess up my sys.path so that I get thrown back to IPython 0.11 (which I don't normally get with or without the virtualenv). There's quite a lot of code to produce those tracebacks. If I switch to plain exception mode (using |
Installing pandas in my virtualenv adds these two lines to
Do you want me to file a bug for this? |
What Cython/Python/etc.? I run this code with 99e2eec and get OSX 10.7 System Python 2.7.1 |
@takluyver is that pandas-related? Must be something weird going wrong in setuptools. @minrk I'll try a newer Python. This is Python 2.7.2 on 64-bit Ubuntu |
@wesm : I suspected ez_setup, but commenting that out from setup.py didn't seem to make a difference. I wonder if it's also related to Cython. I replicated the slow traceback with Python 2.7.2 on 32-bit Ubuntu. |
Just updated to Cython git master and seems be OK now. Unclear why the behavior was only manifesting in the ultratb. Closing the issue (unless you guys want to investigate further) |
Thanks - just for reference, what Cython version were you using before you updated? Could be that they had some actions that are triggered by inspection for better tracebacks, but require some work. |
Appears to be a problem with |
git bisect yielded:
I just verified that the bug is present in Cython |
So I scripted IPython to get a profiling of what's going on and it's extremely perplexing:
hmm, the plot thickens. so something appears to be going very wrong inside |
More: generate_tokens yields about 2.6 million tokens before raising an exception
|
OK so I think this is a bug in IPython. No attempt to tokenize a binary
any proposed solutions? |
We call tokenize when generating the tracebacks, both for the coloured I'd guess it's trying to parse the compiled file, rather than the source, Relevant code is around here: |
Assigning this to myself, since I've touched ultraTB most recently. |
Probably won't work with Cython code, because it's part of the Python standard library. Any binary file should probably just be skipped |
Are there other valid extensions for binary files with Python functions, beyond |
See PR #1341 |
Don't attempt to tokenize binary files for tracebacks. Previously we had been trying and just catching the exception, but in corner cases the tokenizer can run for several seconds before raising an exception (#1317). This skips tokenizing if the file has the extension .so, .pyd or .dll. Closes gh-1317.
Much obliged and thanks as always. |
Don't attempt to tokenize binary files for tracebacks. Previously we had been trying and just catching the exception, but in corner cases the tokenizer can run for several seconds before raising an exception (ipython#1317). This skips tokenizing if the file has the extension .so, .pyd or .dll. Closes ipythongh-1317.
I think this is the fault of IPython and I'm having a hard time coming up with a self-contained example, but basically I'm noticing a major lag between statement execution and IPython coming back with the formatted traceback when the exception is generated in Cython code. For example, with pandas git master (99e2eec, because I'm about to fix this bug), the following code takes about 8.5 seconds to play out:
Running this code
gives me
By contrast, running the same code in the standard Python interpreter gives the stack trace virtually instantaneously.
Any ideas what's wrong? This same problem seems to be present in IPython git master, 0.12, and 0.11.
The text was updated successfully, but these errors were encountered: