gunicorn多进程不死_多进程 Gunicorn 的日志为什么不会错乱?

我的 flask 项目使用 logging 模块,使用 TimedRotatingFileHandler,然后 gunicorn 开了 32 个进程.

logging 模块不是进程安全的,这个 logging 模块的官网有写

Because there is no standard way to serialize access to a single file across multiple processes in Python. If you need to log to a single file from multiple processes, one way of doing this is to have all the processes log to a SocketHandler, and have a separate process which implements a socket server which reads from the socket and logs to file. (If you prefer, you can dedicate one thread in one of the existing processes to perform this function.)

但是我的项目跑了半年,从来没有看到日志错乱的情况,每一条都清清楚楚..

但是看完了这个 issue 表示还是云里雾里没懂,gunicorn 作者给的解释如下

The fd is shared between all workers, and until it isn't over the limit (depending on your system) alls logs will go over it.

求详细解释,谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值