Products Resources Support About Us

Rocket Software

Universe Python and WSGI

I’m trying to see if I can get Universe 11.3.1 and Python configured to serve web apps. I’ve installed apache, mod_wsgi and Flask. I have a simple app that uses u2py.Subroutine to output a simple message. It works!

But… a Universe license is consumed and not released. There is no uvsh process running.

Does anyone know what process is consuming the UV license and how to release it, or end the Python session, when the app is completed?

I removed Flask from the equation, and added these lines to my apache conf file for the site. It seemed to fix the issue of license not being released:
WSGIDaemonProcess testpy.example.com processes=3 threads=15 display-name=%{GROUP}
WSGIProcessGroup testpy.example.com

But… Now I see I am getting Universe abnormal termination errors (ip addresses, etc. removed):

Abnormal termination of UniVerse.
Fault type is 11. Layer type is Unknown.

Connection reset by peer

Failed to proxy response from daemon.

Truncated or oversized response headers received from daemon process
and…
child pid 14942 exit signal Segmentation fault (11)

When I tested accessing UV from python code I found that the UV license is held until the python interpreter stopped running.
I could not find any way of releasing the license and still keep the python interpreter running.

Thank you gregors. I guess I need to figure out how WSGI starts and
stops the Python interpreter/environment when an http request is
received.

If anyone has actually used Python on Universe for web apps, please

let me know how it was done.

Thanks!

When the Python session exits, the Universe license will also be releases. Also, if you execute u2py.run(“LO”) it will exit you out of UniVerse and Python.

Hey @kharker! I have a flask app running on gunicorn and it seems to work fine. I didn’t have to do any special workarounds to get the license to release. I did have to find a way to call start gunciorn via a python script instead of through the terminal.

I subclassed gunicorn’s Base App class:

import gunicorn.app.base
class StandaloneApplication(gunicorn.app.base.BaseApplication):

 def __init__(self,app,options=None):
    ...

then create an instance with a reference to my flask app and run it:

StandaloneApplication(application, options).run()