Skip to content

Commit

Permalink
Fix race condition in luigi.lock.acquire_for (spotify#2357)
Browse files Browse the repository at this point in the history
  • Loading branch information
StasDeep committed Jul 30, 2018
1 parent 7d2c557 commit 0b82f1e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions luigi/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ def acquire_for(pid_dir, num_available=1, kill_signal=None):

# Check if there is a pid file corresponding to this name
if not os.path.exists(pid_dir):
os.mkdir(pid_dir)
os.chmod(pid_dir, 0o777)
# Try/except for handling race condition
try:
os.mkdir(pid_dir)
os.chmod(pid_dir, 0o777)
except OSError:
pass

# Let variable "pids" be all pids who exist in the .pid-file who are still
# about running the same command.
Expand Down

0 comments on commit 0b82f1e

Please sign in to comment.