How to put debugger in uwsgi environment? Of course we do not have access to terminal in that case but we can use remote debugger. I have found very small and simply debugger rpdb:
http://tamentis.com/projects/rpdb/
Simply install it by pip and then put in the code:
import rpdb; rpdb.set_trace()
By default, rpdb listen on 4444 port so the next step is to connect to it by e.g. nc:$ nc zuzia 4444
[teodor@zuzia production]$ nc zuzia 4444 --Call-- > /home/teodor/project/test/lib/python2.7/site-packages/rpdb/__init__.py(37)shutdown() -> def shutdown(self): (Pdb) w /home/teodor/project/test/lib/python2.7/site-packages/django/core/management/commands/runserver.py(107)inner_run() -> run(self.addr, int(self.port), handler, ipv6=self.use_ipv6) /home/teodor/project/test/lib/python2.7/site-packages/django/core/servers/basehttp.py(696)run() -> httpd.serve_forever() /usr/lib64/python2.7/SocketServer.py(227)serve_forever() -> self._handle_request_noblock() /usr/lib64/python2.7/SocketServer.py(284)_handle_request_noblock() -> self.process_request(request, client_address) /usr/lib64/python2.7/SocketServer.py(310)process_request() -> self.finish_request(request, client_address) /usr/lib64/python2.7/SocketServer.py(323)finish_request() -> self.RequestHandlerClass(request, client_address, self) /home/teodor/project/test/lib/python2.7/site-packages/django/core/servers/basehttp.py(570)__init__() -> BaseHTTPRequestHandler.__init__(self, *args, **kwargs) /usr/lib64/python2.7/SocketServer.py(639)__init__() -> self.handle() /home/teodor/project/test/lib/python2.7/site-packages/django/core/servers/basehttp.py(615)handle() -> handler.run(self.server.get_app()) /home/teodor/project/test/lib/python2.7/site-packages/django/core/servers/basehttp.py(283)run() -> self.result = application(self.environ, self.start_response) /home/teodor/project/test/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py(68)__call__() -> return self.application(environ, start_response) /home/teodor/project/test/lib/python2.7/site-packages/django/core/handlers/wsgi.py(273)__call__() -> response = self.get_response(request) /home/teodor/project/test/lib/python2.7/site-packages/django/core/handlers/base.py(111)get_response() -> response = callback(request, *callback_args, **callback_kwargs) /media/Crypted/teodor/projects/test/web/views.py(525)wrapper() -> return panel_view(request, *args, **kw) /media/Crypted/teodor/projects/test/web/views.py(540)test() -> import rpdb; rpdb.set_trace() /home/teodor/project/test/lib/python2.7/site-packages/rpdb/__init__.py(62)set_trace() -> debugger.shutdown() > /home/teodor/project/test/lib/python2.7/site-packages/rpdb/__init__.py(37)shutdown() -> def shutdown(self): (Pdb)
1 comment:
Your stack trace seems to be showing the same bug I have encountered. Notice how your context is within the shutdown() method of rpdb.Rpdb? If you do this, you'll see that you are actually within an exception:
import sys
sys.exc_info()
In my case, I see this:
(, AttributeError("Rpdb instance has no attribute 'do_sys'",), )
Does this actually work for you in uWSGI?
Post a Comment