In multi-threads/multi-processes, tasks can be easily obtained through queue or the like. But when the task is completed, in order to count the number of completed tasks, a value needs to be accumulated.
In the current multi-thread/multi-process situation. I use the lock of the thread/the lock of the manager process of the process to deal with the synchronization problem of counting.
But it feels too inefficient. Not elegant enough.
Is there any better way to handle this?
I feel like this kind of question should be used frequently. Perfect solutions should already exist.
It’s just that I haven’t noticed it yet.
PHP中文网2017-06-12 09:26:09
The problem of inter-process communication can be solved in the way you like (familiar and usable).
One way is provided below:
zmq’s pushpull mode
http://learning-0mq-with-pyzm...