Unable to debug 4.0.2 anymore (unlike 3.0.x)

20 views
Skip to first unread message

Vlad S.

unread,
Jun 23, 2021, 2:20:30 PM6/23/21
to Review Board Development
Hi,

4.0.2 seems to not support python debugger anymore.
3.0.20 could be started with reviewboard.wsgi like that -

import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = "reviewboard.settings"
os.environ['PYTHON_EGG_CACHE'] = "/var/www/rb/tmp/egg_cache"
os.environ['HOME'] = "/var/www/rb/data"
sys.path = ['/var/www/rb/conf'] + sys.path
import django.core.handlers.wsgi
class Debugger:
    def __init__(self, object):
        self.__object = object

    def __call__(self, *args, **kwargs):
        import pdb, sys
        debugger = pdb.Pdb()
        debugger.use_rawinput = 0
        debugger.reset()
        sys.settrace(debugger.trace_dispatch)

        try:
            return self.__object(*args, **kwargs)
        finally:
            debugger.quitting = 1
            sys.settrace(None)

application = Debugger(django.core.handlers.wsgi.WSGIHandler())


I followed 4.0.2 release notes and it returned:
ImportError: No module named django.core.wsgi

import os
import sys
os.environ['REVIEWBOARD_SITEDIR'] = '/var/www/rb'
from django.core.wsgi import get_wsgi_application

class Debugger:
    def __init__(self, object):
        self.__object = object

    def __call__(self, *args, **kwargs):
        import pdb, sys
        debugger = pdb.Pdb()
        debugger.use_rawinput = 0
        debugger.reset()
        sys.settrace(debugger.trace_dispatch)

        try:
            return self.__object(*args, **kwargs)
        finally:
            debugger.quitting = 1
            sys.settrace(None)

application = Debugger(get_wsgi_application())


Any ideas?

-- Vlad

Christian Hammond

unread,
Jun 25, 2021, 4:30:38 PM6/25/21
to reviewb...@googlegroups.com
That module should be there. Make sure you’re running under the expected versions of Python and Django at the top of the script:

import django
Import says
print(django.VERSION)
print(sys.version_info)

Christian



--

---
You received this message because you are subscribed to the Google Groups "Review Board Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/reviewboard-dev/bf3defae-56e6-47b0-8cf6-8c3efccfc818n%40googlegroups.com.
--
--
Christian Hammond
President/CEO of Beanbag
Makers of Review Board

Vlad S.

unread,
Jul 1, 2021, 4:39:57 PM7/1/21
to Review Board Development
Import says:
(1, 11, 29, u'final', 0)
sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0)

and mod_wsgi-express log says:
ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

пятница, 25 июня 2021 г. в 23:30:38 UTC+3, Christian Hammond:

Christian Hammond

unread,
Jul 1, 2021, 4:47:49 PM7/1/21
to reviewb...@googlegroups.com
Hi Vlad,

Can you try changing that wsgi import to:

    from reviewboard.wsgi import application

I think that's where things have gone wrong.

Christian

Vlad S.

unread,
Jul 1, 2021, 5:23:56 PM7/1/21
to Review Board Development
it ends up with

[..]application = Debugger(get_wsgi_application())
[..] NameError: name 'get_wsgi_application' is not defined

четверг, 1 июля 2021 г. в 23:47:49 UTC+3, Christian Hammond:

Christian Hammond

unread,
Jul 1, 2021, 7:12:26 PM7/1/21
to reviewb...@googlegroups.com
You'll need the `application` import from reviewboard.wsgi. You shouldn't call `get_wsgi_application()` yourself.

Christian

Vlad S.

unread,
Jul 2, 2021, 4:51:42 AM7/2/21
to Review Board Development
says something different:

# If you see these lines:
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
# Change them to:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

My initial idea was to get pdb console to debug rare complicated cases.
I run RB with mod_wsgi-express:

/home/venvs/rb/bin/mod_wsgi-express start-server --user apache --group apache --deadlock-timeout 600 --enable-debugger --debugger-startup --envvars-script ./envvars /var/www/rb.example.com/htdocs/reviewboard.wsgi

perhaps python debugger is not the best way to debug RB.

-- Vlad
пятница, 2 июля 2021 г. в 02:12:26 UTC+3, Christian Hammond:

Christian Hammond

unread,
Jul 2, 2021, 3:16:14 PM7/2/21
to reviewb...@googlegroups.com
That information only applies if you still have the old environment settings (meaning our automated upgrade attempt failed). For your case, you have part of the new setup (stripping away the old environment settings and adding REVIEWBOARD_SITEDIR) but you’re not using our import, which makes use of that to set up the rest.

Christian


Reply all
Reply to author
Forward
0 new messages