Troubleshooting wsgi file

Tom Ekberg <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <CO3PR08MB79571305214FAFBC68F80EE0CA879@CO3PR08MB7957.namprd08.prod.outlook.com>
On an Ubuntu 22.04 host I'm running apache 2.4.52 with python 3.10, using roundup 2.1 to execute a wsgi.py file. After running it (bringing up the URL in a browser) the apache error.log says:

[Mon Jul 11 08:53:50.070418 2022] [wsgi:error] [pid 60096:tid 139981150303808] [remote 10.67.80.23:64993] mod_wsgi (pid=60096): Exception occurred processing WSGI script '/mnt/trackers/it_test/apache/wsgi.py'.
[Mon Jul 11 08:53:50.070531 2022] [wsgi:error] [pid 60096:tid 139981150303808] [remote 10.67.80.23:64993] RuntimeError: response has not been started

It provided no detail about the exception. I looked at the other 2 log files, access.log and other_vhosts_access.log, which indicated activity at that time, but provided no detail regarding the exception. Nothing is written to /tmp/wsgi.log.

I can run the wsgi.py file from the command line and it works fine. It also writes to /tmp/wsgi.log.

>>> import wsgi
>>> wsgi.app
<roundup.cgi.wsgi_handler.RequestDispatcher object at 0x7f76ae028be0>
>>> d = dict(PATH_INFO='/', REQUEST_METHOD='GET')
>>> d['wsgi.input'] = ''
>>> >>> wsgi.application(d, '')
[]

There are differences between my wsgi.py (attached, see below) and Roundup's frontends/wsgi.py, mostly so I could add debugging statements and change sys.path. I made sure the sys.path directories mentioned in my wsgi.py exist. This one is for roundup:

$ ls -dl /usr/local/share/virtualenvs/tracker-env/lib/python3.10/site-packages/roundup
drwxr-xr-x 8 root root 4096 May 26 09:29 /usr/local/share/virtualenvs/tracker-env/lib/python3.10/site-packages/roundup

The other sys.path change is for xapian:

$ ls -dl /usr/lib/python3/dist-packages/xapian/
drwxr-xr-x 3 root root 4096 May 25 13:54 /usr/lib/python3/dist-packages/xapian/

I cut/pasted these paths from the attached wsgi.py file. The wsgi.py ownership and group is roundup, and the mode is 744.

Do you have an idea how I can get more data to determine what the problem is with the erroring wsgi.py file?
----- attachment -----
import sys
# Fix sys.path to contain the VENV path.
# The apt package python3-xapian put the xapian python package in python3.
# Put this path last so it only sees the xapian package.
for new_path in ['/usr/local/share/virtualenvs/tracker-env/lib/python3.10/site-packages',
                 '/usr/lib/python3/dist-packages']:
    if new_path not in sys.path:
        sys.path.append(new_path)

from roundup.cgi.wsgi_handler import RequestDispatcher
tracker_home = '/mnt/trackers/it_test'
app = RequestDispatcher(tracker_home)

debug = True
# Store the environment into a log file.

from datetime import datetime
def debug_log(message):
    with open('/tmp/wsgi.log', 'a') as log:
        now = datetime.now()
        log.write('{now} {message}\n'.format(**locals()))

def application(environ, start_response):
    """
    The main WSGI application.
    """
    if debug:
        debug_log(environ)
        debug_log(sys.path)
    return app(environ, start_response)


Tom Ekberg
Senior Computer Specialist
Department of Laboratory Medicine and Pathology
4th Floor, Pat Steel Building, currently WFH
Home: (253) 561-2509
Email: [email protected]<mailto:[email protected]>

_______________________________________________
Roundup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/roundup-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.