python - flask 进程间通信
高洛峰
高洛峰 2017-04-17 17:39:35
0
4
530

我使用gunicorn开了4个worker, 在发生请求的时候我需要对count变量进行加1, 我怎么保证这个count的正确性而不是被多个进程所抢占。

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(4)
洪涛

It is recommended to use multiprocessing.managers
Introduction: http://www.cnblogs.com/Xjng/p/4902514.html

洪涛

The easiest way is to add a global lock

巴扎黑

If your count is stored in the database, the database will handle concurrency for you.

小葫芦

Can be solved in the database. For example, redis has the INCR command.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template