有一个flask写的接口服务,因为加了缓存服务也只是服务器上本地使用所以只能使用一个work来处理请求,如果只用python server来启动回自动扩展进程,所以配置gunicorn来使用,之前服务的启动的命令为
gunicorn -w 1 -b 0.0.0.0:80 app:app
因为不需要日志,所以就开了个tmux查看进程,结果今天遇到一个错误:
[2022-02-18 14:31:56 +0800] [29517] [INFO] Handling signal: winch
[2022-02-18 14:31:56,651] ERROR in app: Exception on /test [GET]
Traceback (most recent call last):
File "...../flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "...../flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "...../flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "....../flask/_compat.py", line 35, in reraise
raise value
File "......./flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "......./flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/test/app.py", line 46, in response
msg_read=run(value)
File "/home/thread_join_test/app.py", line 30, in run
msg = mq_r.receive()
posix_ipc.SignalError: The wait was interrupted by a signal
经过排查决定在gunicorn上python内置库的冲突上,于是查看gunicorn的文档
查看有没有类似的错误
最后在私人服务器上进行复现,发现是只要我改变xshell界面大小就会发出winch
信号,然后就会报错,但是报错归报错,并没有影响到实际的功能,只是gunicorn自己在管理work时造成的,所以为了避免这个情况,还是将gunicorn放到后台运行就行,gunicorn -w 1 -b 0.0.0.0:80 -D app:app