Return a value that changes whenever another process may have modified the on-disk index (so we drop stale mmaps and re-open). Inode alone is insufficient: concurrent writers keep the same inode while mutating the file, which would otherwise leave this process with
(self)
| 367 | pass |
| 368 | |
| 369 | def _get_cache_id(self): |
| 370 | """ |
| 371 | Return a value that changes whenever another process may have modified |
| 372 | the on-disk index (so we drop stale mmaps and re-open). |
| 373 | |
| 374 | Inode alone is insufficient: concurrent writers keep the same inode |
| 375 | while mutating the file, which would otherwise leave this process with |
| 376 | a permanently stale ``mmap`` view of the index. |
| 377 | """ |
| 378 | try: |
| 379 | st = os.stat(self.path) |
| 380 | if st.st_ino: |
| 381 | return (st.st_ino, st.st_mtime_ns, st.st_size) |
| 382 | return (st.st_mtime, st.st_ctime, st.st_size) |
| 383 | except OSError: |
| 384 | return None |
| 385 | |
| 386 | def _sync_cache_id_after_local_write(self): |
| 387 | """ |
no outgoing calls