Skip to content

Commit

Permalink
add delay to retrieval
Browse files Browse the repository at this point in the history
- allow queue to be filled before being processed
  • Loading branch information
observingClouds committed Dec 8, 2022
1 parent 9173b40 commit e34ac53
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions slkspec/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import re
import threading
import time
import warnings
from collections import defaultdict
from getpass import getuser
Expand Down Expand Up @@ -92,6 +93,7 @@ def __init__(
mode: str = "rb",
touch: bool = True,
file_permissions: int = 0o3777,
sleep: int = 2,
_lock: threading.Lock = _retrieval_lock,
_file_queue: Queue[Tuple[str, str]] = FileQueue,
**kwargs: Any,
Expand All @@ -113,6 +115,7 @@ def __init__(
self.error = "strict"
self.encoding = kwargs.get("encoding")
self.write_through = False
self.sleep = sleep
self._file_queue = _file_queue
print(self._file)
with _lock:
Expand Down Expand Up @@ -152,6 +155,7 @@ def _retrieve_items(self, retrieve_files: list[tuple[str, str]]) -> None:
(output_dir / out_file.name).chmod(self.file_permissions)

def _cache_files(self) -> None:
time.sleep(self.sleep)
with self._lock:
items = []
if self._file_queue.qsize() > 0:
Expand Down

0 comments on commit e34ac53

Please sign in to comment.