FastCGI WSGI library in Python 3?

2019-04-04 10:31发布

Does there exist any library that can serve a WSGI application as a FastCGI server, for Python 3? (So that nginx could then proxy requests to it?)

The Python 3 docs mention flup, but flup doesn't even install in Python 3:

% env3/bin/pip install flup
Downloading/unpacking flup
  Downloading flup-1.0.2.tar.gz (49kB): 49kB downloaded
  Running setup.py (path:/Users/me/tmp/env3/build/flup/setup.py) egg_info for package flup
    Traceback (most recent call last):
      File "", line 17, in 
      File "/Users/me/tmp/env3/build/flup/setup.py", line 2, in 
        from ez_setup import use_setuptools
      File "./ez_setup.py", line 98
        except pkg_resources.VersionConflict, e:
                                            ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "", line 17, in 

  File "/Users/me/tmp/env3/build/flup/setup.py", line 2, in 

    from ez_setup import use_setuptools

  File "./ez_setup.py", line 98

    except pkg_resources.VersionConflict, e:

                                        ^

SyntaxError: invalid syntax

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in [snip]
Storing debug log for failure in [snip]

5条回答
聊天终结者
2楼-- · 2019-04-04 11:01

There is now module called flup6. Install it using pip

./pip install flup6
查看更多
贪生不怕死
3楼-- · 2019-04-04 11:06

You can use flup-py3 to solve this problem, as :

pip3 install flup-py3

You may need super user privilge to execute this command.

查看更多
看我几分像从前
4楼-- · 2019-04-04 11:13

I am aware of two options

Both support Python 3 and both can create WSGI workers based on other web app code and can be served to NGINX.

As Graham Dumpleton mentioned, CherryPy talks to NGINX via HTTP protocol, while uWSGI talks the 'uwsgi' protocol to nginx instead of the HTTP protocol, although it does also support using HTTP as well. On the application side, both support hosting Python web applications via the WSGI API.

查看更多
姐就是有狂的资本
5楼-- · 2019-04-04 11:19

Use flipflop instead

pip3 install --upgrade flipflop

flipflop is what did the trick for me. flup-py3 has an unresolved issue which has been standing open for a couple of years now.

Do not forget to edit the import line in your .fcgi script to reflect this change towards using flipflop.

查看更多
放荡不羁爱自由
6楼-- · 2019-04-04 11:23

You can use flipflop. It's a simplified fork of flup (contains only the FastCGI part) and works fine with Python 3.

查看更多
登录 后发表回答