I already set the debug=Truethen what is the next ? I use eclipse + pydev for develop environment
Give me some details about tornado debugging will be very appreciate
Use Eclipse, PyDev, PyCharm, or whatever to set a breakpoint at the misbehaving line of code and step through your code from there. Tornado applications are relatively difficult to debug because the stack trace is less clear than in multithreaded code. Step through your code carefully. If you use coroutines, you should become familiar with the implementation of gen.Runner so you can understand what your code does during a "yield".
Related
I went through a few articles about how to setup VSCode to work with python for the first time, and I'm very confused.
To me, VSCode seems messy - so many json settings which I manually need to configure...
Anyway, I now have 3 ways of running my python script:
F5, which runs via the terminal
Run (Ctrl+Shift+D), via Watson
Run via Code Runner
I don't understand the differences between the different methods of running my script.
Can someone please give me a short intro?
Thanks!
Terminal:
Terminal is fast and efficient to use. It also provides detailed information about the errors in your programs. And it is widely used buy a lot of Python programmers.
Watson:
It provides developer tools for more advanced users. You can get more information about that from here. Not recommended for a beginner.
Code Runner:
Code runner is also used to see the the results of the programs but it is read only, and there can be some problems with that. As an example if you are building an application that takes the input from the user in Python, you can't do that via code runner.
So which one is the best?
I would recommend using the Terminal (F5), because it is good for small programs, you get detailed information about your apps, the problems with your apps and some other options too. It is also fast and easy to use for a beginner.
Hope it's clear now.
I am not a native English speaker. When I code with Python, I often make spelling mistakes and get 'NameError' Exceptions. Unit test can solve some problems but not all. Because one can hardly construct test cases which cover all logic. So I think a tool that detect such errors would help me a lot but I searched Google and cannot find it.
I believe that testing your code via a static analyzer (e.g. pylint) will help a lot.
Another hint: you can use a fancy IDE with smart auto-completion which will reduce the amount of such mistakes.
I prefer eclipse with pydev integration for python development projects.
It will solve your purpose and will show you the errors in RED before you run your program. but it requires your project to be properly configured under eclipse as below:
Configure Python interpreter after integrating PyDev with eclipse
Create / Import your project & set as python pydev project
Configure your source folder ( Give information to eclipse that which folders contains python source code under your entire project tree)
You're done & setup now for general python programming setup.
Further more you can integrate your Eclipse/Pydev project with pylint as mentioned by BasicWolf which checks your code quality & bugs on the go while you're coding.
References:
Installing PyDev under Eclise
Eclipse PyDev Integration
Troubleshooting PyDev/PyLint Integration
pylint can help here. It will report those locations as
E: 2,6: Undefined variable "foo"
for example.
You could get an IDE which helps a bit with autocompletion of names, though not in all situations. PyDev is one such IDE with autocompletion; PyCharm is another (not free).
Using autocomplete is probably your best bet to solve your problem in the long term. Even if you find a tool which attempts to correct such spelling errors, that will not solve the initial problem and will probably just cause new ones.
Is there a way to integrate standard Python documentation into Eclipse? So it will be possible to press F1 on an API function and get its description in the Help view of Eclipse.
I use PyDev.
Thanks.
I've had the same problem, so I kinda made an Eclipse plugin for that purpose.
Or download from Sourceforge
PyDev, nor Eclipse, does not provide integrated on-line help for the Python documentation. Unlike with Java, Python API source code documenting has several competing documentation standards and implementing support for them would be difficult.
However if the function under the cursor can be resolved its docstring is shown in a pop-up note.
http://www.python.org/dev/peps/pep-0257/
Also because Python is dynamic language, as opposite to static languages like Java, you rarely can resolve functions to their source in code development time.
Using Python console debugger you can use the help() command when the application is being run
>>> help(obj.myfuction)
None that I know of, but that would be very useful in pydev. You should suggest it in the eclipse pydev forum ,or code it yourself! If I was still a CS student I'd help..
Zeal - https://zealdocs.org/
Although I do not see how to integrate it in Eclipse, it is pretty useful next to it on your desktop. And it is not only Python docs, but may more. A real life saving stuff this Zeal docs!
Just a footnote: I do not use Eclipse that much as I switched to PyCharm and Jupyther.
I am trying to use GDB's reverse debugging with a Django application. I get it running in GDB, but I can't make it run backwards.
I stopped my Django app with Ctrl-Z and then entered reverse-next at the gdb prompt, getting the error message "Target multi-thread does not support this command."
Am I doing it wrong? Isn't this possible? Both?
Before you can use GDB for reverse debugging, you must tell it to record your program execution (so it can play it back) via target record command, as documented here.
I am not sure this will help you debug your Django application though -- GDB is well suited for debugging "native" code (compiled C/C++), and is not well suited for debugging "interpreted" code (in either forward or reverse direction).
RevDB
https://bitbucket.org/pypy/revdb
https://morepypy.blogspot.co.uk/2016/07/reverse-debugging-for-python.html
This project aims to allow pdb-like reverse debugging, which is likely what you want unless you are debugging the Python interpreter itself.
It is still in early stages as of 2017, and you must build from source.
How to question that does not mention GDB: Is it possible to step backwards in pdb?
Finally, GDB reverse debugging is quite immature, e.g. does not deal with AVX extensions Disable AVX-optimized functions in glibc (LD_HWCAP_MASK, /etc/ld.so.nohwcap) for valgrind & gdb record , so I strongly recommend using rr instead: https://github.com/mozilla/rr (on which RevDB claims to take inspiration from).
Related for JavaScript: How to go backwards while debugging Javascript in Chrome sources debugging?
That's an amazingly good question.
My first impulse would be to ensure I was using IPython as my shell for django and see if it's pdb support would help in this case. Pdb should have a very similar interface to gdb. As I recall, gdb is what's used to debug C/C++ programs, while django is being executed by a python interpreter. Using Pdb is here:
http://ericholscher.com/blog/2008/aug/31/using-pdb-python-debugger-django-debugging-series-/
Also you might want to try using django-extensions, for access to the werkzeug debugging view.
Anyone know how to debug Python using PDB in Windows XP?
My system has some deadlock. I want to use PDB to track my system.
My Config: VC 2005, Python2.7
I would recommend using the Winpdb GUI debugger, which works great on Windows (and other OSes too--the name is misleading) and can attach to processes after launch. There's a great tutorial that gets you all the basics, which has been enough for me every time I've needed it, at least. Good luck!
I think the following page will help you. It's pydev with Eclipse.
http://pydev.org/manual_adv_remote_debugger.html