/usr/local/lib64/python3.6/site-packages/torch/utils
NameSizeModeActions
backcompat/-0755rm
benchmark/-0755rm
bottleneck/-0755rm
data/-0755rm
ffi/-0755rm
hipify/-0755rm
model_dump/-0755rm
tensorboard/-0755rm
__pycache__/-0755rm
bundled_inputs.py222820644editdlrm
checkpoint.py121650644editdlrm
collect_env.py167230644editdlrm
cpp_extension.py877390644editdlrm
dlpack.py20450644editdlrm
file_baton.py13960644editdlrm
hooks.py73730644editdlrm
mkldnn.py72190644editdlrm
mobile_optimizer.py62640644editdlrm
model_zoo.py1170644editdlrm
show_pickle.py51690644editdlrm
throughput_benchmark.py63870644editdlrm
_cpp_extension_versioner.py19910644editdlrm
_crash_handler.py6730644editdlrm
_python_dispatch.py16360644editdlrm
_pytree.py81740644editdlrm
__init__.py6350644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/utils/file_baton.py (1396B)
import os import time class FileBaton: '''A primitive, file-based synchronization utility.''' def __init__(self, lock_file_path, wait_seconds=0.1): ''' Creates a new :class:`FileBaton`. Args: lock_file_path: The path to the file used for locking. wait_seconds: The seconds to periorically sleep (spin) when calling ``wait()``. ''' self.lock_file_path = lock_file_path self.wait_seconds = wait_seconds self.fd = None def try_acquire(self): ''' Tries to atomically create a file under exclusive access. Returns: True if the file could be created, else False. ''' try: self.fd = os.open(self.lock_file_path, os.O_CREAT | os.O_EXCL) return True except FileExistsError: return False def wait(self): ''' Periodically sleeps for a certain amount until the baton is released. The amount of time slept depends on the ``wait_seconds`` parameter passed to the constructor. ''' while os.path.exists(self.lock_file_path): time.sleep(self.wait_seconds) def release(self): '''Releases the baton and removes its file.''' if self.fd is not None: os.close(self.fd) os.remove(self.lock_file_path)