Simple folder/file lock handler
There is a race condition here:
while os.path.exists(self._lock_file_path):
...
with open(self._lock_file_path, &quot;w&quot;) as fn:

The file could have been created by the other process in between. You need to check file existence and create the file in one operation.
Since python 3.3 there is a special open mode x for this use case:

open for exclusive creation, failing if the file already exists

For example:
while (time.time() - start_time) &lt; self._lock_time_out:
    try:
        with open(self._lock_file_path, &quot;x&quot;) as fn:
            fn.write(str(os.getpid()))
    except FileExistsError:
        time.sleep(5)