Skip to content

Commit

Permalink
Merge pull request #479 from kubilus1/readseek
Browse files Browse the repository at this point in the history
Lock multi-thread seek and read for same FH.
  • Loading branch information
kubilus1 committed Jan 16, 2024
2 parents 7f5b3f2 + c36f9b9 commit 1e81d5c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ jobs:

- name: Setup
run: |
#choco --yes install winfsp
py -m pip install -U pytest
py -m pip install -U -r requirements.txt
python -m pip install -U -r requirements.txt
- name: Test
run: cd autoortho && py -m pytest -v test_getortho.py test_pydds.py test_downloader.py
run: cd autoortho && python -m pytest -v test_getortho.py test_pydds.py test_downloader.py
9 changes: 6 additions & 3 deletions autoortho/autoortho_fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class AutoOrtho(Operations):
path_dict = {}
tile_dict = {}

fh_locks = {}

fh = 1000

default_uid = -1
Expand Down Expand Up @@ -390,9 +392,10 @@ def read(self, path, length, offset, fh):
return data

if not data:
os.lseek(fh, offset, os.SEEK_SET)
data = os.read(fh, length)
log.debug(f"READ: Read {len(data)} bytes.")
with self.fh_locks.setdefault(fh, threading.Lock()):
os.lseek(fh, offset, os.SEEK_SET)
data = os.read(fh, length)
log.debug(f"READ: Read {len(data)} bytes.")

return data

Expand Down

0 comments on commit 1e81d5c

Please sign in to comment.