fcache icon indicating copy to clipboard operation
fcache copied to clipboard

`'cs'` cache option is not thread safe

Open arindamchoudhury opened this issue 7 years ago • 4 comments

Hi,

I am using fcache version 0.4.7

I am getting the following error:

  File "/root/app/collector/libs/eccache.py", line 15, in __init__
    self.cache = FileCache(name, flag='cs', app_cache_dir=cache_dir)
  File "/usr/local/lib/python2.7/site-packages/fcache/cache.py", line 121, in __init__
    self.create()
  File "/usr/local/lib/python2.7/site-packages/fcache/cache.py", line 141, in create
    os.makedirs(self.cache_dir)
  File "/usr/local/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)

arindamchoudhury avatar Jul 19 '18 13:07 arindamchoudhury

Hello! Can you try manually checking if Python sees the directory as already existing?

>>> import os
>>> cache_dir = '/my/cache/dir'
>>> os.path.exists(cache_dir)

If it returns False, but the directory really does exist, it’s likely a permission issue.

tsroten avatar Jul 19 '18 22:07 tsroten

Hi,

The operation is not thread-safe. When i use more than one thread, i get this error.

arindamchoudhury avatar Jul 23 '18 15:07 arindamchoudhury

@arindamchoudhury Oh okay, that makes sense! I'll label this as a bug in case anyone sees it and wants to submit a pull request to fix it.

tsroten avatar Jul 23 '18 23:07 tsroten

I got some kind of solution here, but it is entirely for multiprocess: https://github.com/tsroten/fcache/issues/26

May be you find it useful.

andry81 avatar Nov 09 '19 21:11 andry81