How to efficiently synchronize data in python multi-process or multi-thread?
怪我咯
怪我咯 2017-06-12 09:24:09
0
1
870

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.

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
Ty80

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...

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