Merge branch '18842-arv-mount-disk-config' refs #18842
[arvados.git] / sdk / python / arvados / diskcache.py
index 74b2a77b28506b2b5fd15b64b7977d877ea0ace8..15afa23a8dc3a4c6fdc0052c8d0c16a0ecc55b64 100644 (file)
@@ -36,15 +36,18 @@ class DiskCacheSlot(object):
         try:
             if value is None:
                 self.content = None
+                self.ready.set()
                 return
 
             if len(value) == 0:
                 # Can't mmap a 0 length file
                 self.content = b''
+                self.ready.set()
                 return
 
             if self.content is not None:
                 # Has been set already
+                self.ready.set()
                 return
 
             blockdir = os.path.join(self.cachedir, self.locator[0:3])
@@ -66,6 +69,8 @@ class DiskCacheSlot(object):
             tmpfile = None
 
             self.content = mmap.mmap(self.filehandle.fileno(), 0, access=mmap.ACCESS_READ)
+            # only set the event when mmap is successful
+            self.ready.set()
         finally:
             if tmpfile is not None:
                 # If the tempfile hasn't been renamed on disk yet, try to delete it.