Skip to content

Commit

Permalink
Fix (sys.meta_path is None, Python is likely shutting down) (#116)
Browse files Browse the repository at this point in the history
* Fix (sys.meta_path is None, Python is likely shutting down).

* Add warning.
  • Loading branch information
knighton authored Jan 9, 2023
1 parent 1bec8b1 commit fb5c839
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions streaming/base/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,14 @@ def __init__(self,
# Partition state.
self._partition_state = None

# Initialize the World context.
#
# Beware: This information is for the per-rank process. DataLoader worker processes may see
# different values for these fields. We are saving the rank World here because we cannot
# instantiate a World inside the StreamingDataset destructor.
self._rank_world = world = World()

# Seed is set below.
world = World()
self.num_canonical_nodes = num_canonical_nodes
self.batch_size = batch_size
self.shuffle_seed = shuffle_seed
Expand Down Expand Up @@ -779,7 +785,7 @@ def _cleanup_shared_memory(self, shm: Any, world: World) -> None:

def __del__(self):
# Wait for the local rank 0 process
world = World()
world = self._rank_world
wait_for_local_leader(world)

# Clean up shared memory resources
Expand Down

0 comments on commit fb5c839

Please sign in to comment.