Skip to content

Commit

Permalink
Fixes for multiprocessing on Windows/Mac (Closes baudm#6)
Browse files Browse the repository at this point in the history
- Remove reference to Environment once LmdbDataset is removed
- Define _create_env() as a method instead of a lambda
  • Loading branch information
baudm committed Aug 12, 2022
1 parent 1627112 commit 141e5ab
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions strhub/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def __init__(self, root: str, charset: str, max_label_len: int, min_image_dim: i
remove_whitespace: bool = True, normalize_unicode: bool = True,
unlabelled: bool = False, transform: Optional[Callable] = None):
self._env = None
self._create_env = lambda: lmdb.open(root, max_readers=1, readonly=True, create=False,
readahead=False, meminit=False, lock=False)
self.root = root
self.unlabelled = unlabelled
self.transform = transform
self.labels = []
Expand All @@ -70,6 +69,11 @@ def __init__(self, root: str, charset: str, max_label_len: int, min_image_dim: i
def __del__(self):
if self._env is not None:
self._env.close()
self._env = None

def _create_env(self):
return lmdb.open(self.root, max_readers=1, readonly=True, create=False,
readahead=False, meminit=False, lock=False)

@property
def env(self):
Expand Down

0 comments on commit 141e5ab

Please sign in to comment.