Reputation: 31
using cProfile of python, I cprofiled my code, but I keep getting this error related with compile() and null character which I can't quite understand.
The error message is:
[cProfileV]: cProfile output available at http://127.0.0.1:4000 Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/bin/cprofilev", line 9, in load_entry_point('CProfileV==1.0.6', 'console_scripts', 'cprofilev')() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cprofilev.py", line 217, in main code = compile(fp.read(), progname, 'exec') TypeError: compile() expected string without null bytes
Is it a problem with my client code, or the server just isn't up?
Thank you in advance.
Upvotes: 3
Views: 2143
Reputation: 739
I believe the error is caused by a mismatch between versions of cprofile and cprofilev.
Cprofilev can be run directly using:
python -m cprofilev your_script.py
Upvotes: 3
Reputation: 1865
This has been asked before.
Anyhow, the error means you're recieving a string which you cannot read well, because it includes nulls. That means the server is up & responding but you cannot read the respond properly. That is because it's in another format, which is very likely JSON. try using the JSON module, included in python 2.6 and beyond; you could see some examples for it, here. If you'll provide us with your code, I can help you convert your application into a JSON-friendly one. :)
Upvotes: 0