pyshmht icon indicating copy to clipboard operation
pyshmht copied to clipboard

not support multi-process share-memory

Open chinesejie opened this issue 11 years ago • 2 comments

I have test the code as follow.

  1. Cacher.py set ht['b']='b' print ht['b'] run "python -i Cacher.py" not close this process
  2. Cacher2.py just print ht['b'] without setter run "python -i Cacher2.py" cannot get the value.

As I known, I think shared-memory could be read by two processes. How do you think about it.

chinesejie avatar Nov 22 '14 16:11 chinesejie

sorry about that.

  1. I forget to use ht.write_back() to update the item.
  2. And the code "ht = MemCacher('test.Cacher', 1024, True)" will empty the mmap file. It should change to be "ht = MemCacher('test.Cacher', 1024, False)" Anyway, it is a really nice project.

chinesejie avatar Nov 22 '14 19:11 chinesejie

这个扩展只是写着玩玩,我们的项目有多个python进程顺序跑,但是希望在进程之间共享一份数据,需求中暂时没有并发,而且真要写起来貌似也还是挺麻烦的,所以就偷懒了……目前并发读是没问题的,但是如果并发写的话估计是要崩的,慎用……

felix021 avatar Dec 13 '14 14:12 felix021