Why a manager.dict need to be lock before writing

2019-08-18 07:31发布

I spend my day correcting a bug with a multiprocess pool in Python 3.6. I was sending around 550 requests to an api in 15 seconds. For each request i was adding datas inside a Multiprocess.Manager.dict(). But i didn't have all my datas in the end. The issue I found to correct the bugs was to lock.acquire() before writing in that share dict. I did know about lock mechanics etc but i thought that a manager.dict did handle the case that many process can add datas inside. But it seems not.

Do you have more details about this mechanics ? It seems very strange that a shared variable for many process didnt manage the simultaneous writing...

Thanks :)

0条回答
登录 后发表回答