gpt4 book ai didi

Python 和 uWSGI : Unhandled object from iterator

转载 作者:行者123 更新时间:2023-12-03 08:17:00 26 4
gpt4 key购买 nike

请帮助我理解如何使用uWSGI。这是我的 Python 文件:

# cat /var/www/test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return ["<h1 style='color:blue'>Test</h1>"]

我用这个命令启动uWSGI:

# uwsgi --socket 0.0.0.0:8080 --protocol=http --plugin python39 --pythonpath /var/www/ -w test

并在控制台中得到这个:

*** Starting uWSGI 2.0.19.1 (64bit) on [Sat Sep  4 20:02:16 2021] ***
compiled with version: 10.3.0 on 02 September 2021 21:45:57
os: Linux-5.10.52-gentoo-x86_64 #5 SMP Fri Aug 20 00:32:31 EEST 2021
nodename: virtuala-servilo-2
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /tmp
detected binary path: /usr/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7854
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
*** RRDtool library available at 0x55ab7e467000 ***
uwsgi socket 0 bound to TCP address 0.0.0.0:8080 fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.9.6 (default, Aug 8 2021, 17:26:32) [GCC 10.3.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55ab7e46fed0
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
added /var/www/ to pythonpath.
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x55ab7e46fed0 pid: 14817 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 14817, cores: 1)

看起来不错,但是当我尝试连接到我的服务器时,我收到的是控制台:

[ERROR] Unhandled object from iterator: "<h1 style='color:blue'>Test</h1>" (0x7f4fe2a28c30)
[pid: 14817|app: 0|req: 1/1] 85.143.221.42 () {24 vars in 284 bytes} [Sat Sep 4 20:02:21 2021] GET / => generated 0 bytes in 0 msecs (HTTP/1.1 200) 1 headers in 44 bytes (1 switches on core 0)

但是,如果我将脚本中的最后一个字符串替换为 yield None - 我不会收到此错误。

最佳答案

根据doc ,python3要求返回类型为字节。

关于Python 和 uWSGI : Unhandled object from iterator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69057420/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com