Rate this Page

StreamWrapper#

class torch.utils.data.datapipes.utils.common.StreamWrapper(file_obj, parent_stream=None, name=None)[source]#

StreamWrapper is introduced to wrap file handler generated by DataPipe operation like FileOpener.

StreamWrapper would guarantee the wrapped file handler is closed when it’s out of scope.

autoclose()[source]#

Automatically close stream when all child streams are closed or if there are none.

classmethod close_streams(v, depth=0)[source]#

Traverse structure and attempts to close all found StreamWrappers on best effort basis.