tamentis / rpdb

Wrapper around pdb allowing remote debugging via netcat or telnet. This is especially useful in a Tomcat/Jython environment where little debugging tools are available.
BSD 2-Clause "Simplified" License
130 stars 44 forks source link

rpdb.set_trace() always end up in shutdown() function #3

Closed k4ml closed 11 years ago

k4ml commented 12 years ago

It work fine if I used the following:-

import rpdb debugger = rpdb.Rpdb('127.0.0.1', 4444) debugger.set_trace()

but when using the shortcut import rpdb;rpdb.set_trace() it always end up in the Rpdb.shutdown(). So I removed the call to shutdown() in the finally block and it seem to work now.

def set_trace():
    """Wrapper function to keep the same import x; x.set_trace() interface.

    We catch all the possible exceptions from pdb and cleanup.

    """
    debugger = Rpdb()
    try:
        debugger.set_trace(sys._getframe().f_back)
    except Exception as e:
        print e
djsmith42 commented 11 years ago

I'm having the same issue. According to sys.exc_info(), the complaint is that Rpdb has no attribute "do_sys".

I tried using a modified version of rpdb to add a do_sys attribute, but by assigning it to do_continue and by writing my own no-op do_sys, and this only led to more issues.

tamentis commented 11 years ago

Can you give me some context, what version of Python are you using, what environment?

djsmith42 commented 11 years ago

I am on Ubuntu 10.04 with Python 2.6.5 running under uWSGI 1.2.6.

Note that it works fine under the Django runserver on Ubuntu 12.04 with Python 2.7.3. I don't know if the OS/Python versions have anything to do with it vs. uWSGI itself.

Notice that this well-meaning blogger has the same issue, but probably doesn't realize it (see his console output): http://blog.krajniak.info/2012/05/remote-pdb-and-django.html

zimnyx commented 11 years ago

Same for me under Python 2.7.3, Ubuntu. rpdb==0.1.2

ed@corsa:/tmp$ cat b.py

coding: utf-8

from future import unicode_literals

def pi(): print 1 import rpdb; rpdb.set_trace() print 2 pi()

ed@corsa:/tmp$ python2.7 b.py 1 pdb is running on corsa:4444

ed@corsa:/tmp$ telnet localhost 4444 Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. --Call--

/usr/local/lib/python2.7/dist-packages/rpdb/init.py(37)shutdown() -> def shutdown(self): (Pdb)

tamentis commented 11 years ago

Can you get back to set_trace using the "up" pdb command?

zimnyx commented 11 years ago

Yes:

ed@krab ~ $ telnet krab 4444
Trying 127.0.1.1...
Connected to krab.
Escape character is '^]'.
--Call--
> /usr/local/lib/python2.7/dist-packages/rpdb/__init__.py(37)shutdown()
-> def shutdown(self):
(Pdb) up
> /usr/local/lib/python2.7/dist-packages/rpdb/__init__.py(62)set_trace()
-> debugger.shutdown()
(Pdb) up  
> <ipython-input-1-6aa2ac9c9437>(3)pi()
-> import rpdb; rpdb.set_trace()
(Pdb) 
tamentis commented 11 years ago

I merged the fix from k4ml because I can't remember why I had this finally. Let me know if that works for you (also published on pypi as 0.1.3: https://pypi.python.org/pypi/rpdb/0.1.3)

zimnyx commented 11 years ago

Confirming - under current master issue is fixed. Thanks for your kind support :) Btw 0.1.3 in not installable from pypi using pip. pip install rpdb installs 0.1.2.

tamentis commented 11 years ago

Oops, forgot to do sdist upload. That's fixed now.