MCPcopy Create free account
hub / github.com/pytorch/pytorch / TemporaryFileName

Function TemporaryFileName

torch/testing/_internal/common_utils.py:1183–1197  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

1181if IS_WINDOWS:
1182 @contextmanager
1183 def TemporaryFileName(*args, **kwargs):
1184 # Ideally we would like to not have to manually delete the file, but NamedTemporaryFile
1185 # opens the file, and it cannot be opened multiple times in Windows. To support Windows,
1186 # close the file after creation and try to remove it manually
1187 if 'delete' in kwargs:
1188 if kwargs['delete'] is not False:
1189 raise UserWarning("only TemporaryFileName with delete=False is supported on Windows.")
1190 else:
1191 kwargs['delete'] = False
1192 f = tempfile.NamedTemporaryFile(*args, **kwargs)
1193 try:
1194 f.close()
1195 yield f.name
1196 finally:
1197 os.unlink(f.name)
1198else:
1199 @contextmanager # noqa: T484
1200 def TemporaryFileName(*args, **kwargs):

Calls 1

closeMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…