Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _do_open(self):
basedir = os.path.dirname(self.path)
if basedir:
made_basedir = _ensure_tree(basedir)
if made_basedir:
self.logger.log(_utils.BLATHER,
'Created lock base path `%s`', basedir)
# Open in append mode so we don't overwrite any potential contents of
# the target file. This eliminates the possibility of an attacker
# creating a symlink to an important file in our lock path.
if self.lockfile is None or self.lockfile.closed:
self.lockfile = open(self.path, 'a')