Skip to content

fcache is not multiprocess aware on Windows #26

@andry81

Description

@andry81

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions