我使用gunicorn开了4个worker, 在发生请求的时候我需要对count变量进行加1, 我怎么保证这个count的正确性而不是被多个进程所抢占。
PHP中文网2017-04-17 17:41:35
It is recommended to use multiprocessing.managers
Introduction: http://www.cnblogs.com/Xjng/p/4902514.html
巴扎黑2017-04-17 17:41:35
If your count is stored in the database, the database will handle concurrency for you.
高洛峰2017-04-17 17:41:35
Can be solved in the database. For example, redis has the INCR command.