def METHOD_NAME(self) -> None:
    """Creates the lock file on the file system, with exclusive use.
    If another thread wants to use a concurrent folder/file, but this file is still in use, then wait until the
    current thread releases the lock file.
    """
    start_wait = time.time()
    while True:
        if time.time() - start_wait > self._timeout:  # Timeout expired. Overwrite the lock file.
            try:
                os.remove(self._filename)
            except FileNotFoundError:
                pass  # In case the file is simply not found, continue as normal.
            except OSError:
                pass  # Can happen if the file system is dismounted or permissions have been changed during the runtime, etc.
            except Exception as e:
                stats = None
                try:
                    stats = os.stat(self._filename)
                except:
                    pass
                raise RuntimeError("Failed to remove lock file with stats = {stats}. Exception: {exception}".format(stats = stats, exception = e))
        open_flags = (os.O_CREAT | os.O_EXCL | os.O_WRONLY)
        open_mode = 0o666
        try:
            self._pidfile = os.open(self._filename, open_flags, open_mode)
            break
        except:
            pass
        time.sleep(0.1)