Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fcache is not multiprocess aware on Windows #26

Open
andry81 opened this issue Nov 9, 2019 · 0 comments
Open

fcache is not multiprocess aware on Windows #26

andry81 opened this issue Nov 9, 2019 · 0 comments

Comments

@andry81
Copy link

andry81 commented Nov 9, 2019

I made a detailed explanation here:
https://stackoverflow.com/questions/58781265/portable-way-to-use-a-local-shared-read-write-storage-file-database-as-a-cache

But I suspect this is some kind of a bug.

Platform: Windows 7 x64
Python: x86/3.8.0

Example to repro:

test1.py

from fcache.cache import FileCache
import time
import sys

mycache = FileCache('1')

i = 0
count = 0
y = '111'

#class DummyFile(object):
#  def write(self, x): pass

while True:
  #prev_stderr = sys.stderr
  #sys.stderr = DummyFile()
  try:
    mycache['test'] = y
    mycache.sync()
    x = mycache['test']
    #sys.stderr = prev_stderr
    if x is None:
      print('FAILED', count, x)
    else:
      print('SUCCEED', count, x)
      i = 0
  except:
    #sys.stderr = prev_stderr
    # retry, has meaning on Windows
    i += 1
    if i % 10 == 0:
      # give to scheduler a break
      print('sleep 2')
      time.sleep(.02)
    continue
  count += 1

  if count % 10 == 0:
    # give to scheduler a break
    print('sleep 1')
    time.sleep(.02)

test2.py

<<<The same code as above>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant