[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][ftp-team/dak][master] Adjust lockfile handling in python



Title: GitLab

Joerg Jaspert pushed to branch master at Debian FTP Team / dak

Commits:

5 changed files:

Changes:

  • dak/new_security_install.py
    ... ... @@ -93,7 +93,7 @@ def _do_Approve():
    93 93
         lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'unchecked.lock'), os.O_RDWR | os.O_CREAT)
    
    94 94
         while True:
    
    95 95
             try:
    
    96
    -            fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    
    96
    +            fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    
    97 97
                 break
    
    98 98
             except IOError as e:
    
    99 99
                 if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
    
    ... ... @@ -107,6 +107,9 @@ def _do_Approve():
    107 107
         for queue in ("embargoed",):
    
    108 108
             spawn("dak process-policy {0}".format(queue))
    
    109 109
     
    
    110
    +    # Unlock, the cronscript coming up locks itself where needed.
    
    111
    +    fcntl.flock(lock_fd, fcntl.LOCK_UN)
    
    112
    +
    
    110 113
         # 3. Run all the steps that are needed to publish the changed archive
    
    111 114
         print "Doing loadsa stuff in the archive, will take time, please be patient"
    
    112 115
         os.environ['configdir'] = '/srv/security-master.debian.org/dak/config/debian-security'
    

  • dak/process_upload.py
    ... ... @@ -545,9 +545,9 @@ def main():
    545 545
     
    
    546 546
         # Obtain lock if not in no-action mode and initialize the log
    
    547 547
         if not Options["No-Action"]:
    
    548
    -        lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'dinstall.lock'), os.O_RDWR | os.O_CREAT)
    
    548
    +        lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'process-upload.lock'), os.O_RDWR | os.O_CREAT)
    
    549 549
             try:
    
    550
    -            fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    
    550
    +            fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    
    551 551
             except IOError as e:
    
    552 552
                 if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
    
    553 553
                     utils.fubar("Couldn't obtain lock; assuming another 'dak process-upload' is already running.")
    

  • dak/transitions.py
    ... ... @@ -223,7 +223,7 @@ def lock_file(f):
    223 223
         for retry in range(10):
    
    224 224
             lock_fd = os.open(f, os.O_RDWR | os.O_CREAT)
    
    225 225
             try:
    
    226
    -            fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    
    226
    +            fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    
    227 227
                 return lock_fd
    
    228 228
             except OSError as e:
    
    229 229
                 if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EEXIST':
    

  • dak/update_db.py
    ... ... @@ -224,13 +224,13 @@ Updates dak's database schema to the lastest version. You should disable crontab
    224 224
     
    
    225 225
             try:
    
    226 226
                 if os.path.isdir(cnf["Dir::Lock"]):
    
    227
    -                lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'dinstall.lock'), os.O_RDWR | os.O_CREAT)
    
    228
    -                fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    
    227
    +                lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'daily.lock'), os.O_RDWR | os.O_CREAT)
    
    228
    +                fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    
    229 229
                 else:
    
    230 230
                     utils.warn("Lock directory doesn't exist yet - not locking")
    
    231 231
             except IOError as e:
    
    232 232
                 if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
    
    233
    -                utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.")
    
    233
    +                utils.fubar("Couldn't obtain lock, looks like archive is doing something, try again later.")
    
    234 234
     
    
    235 235
             self.update_db()
    
    236 236
     
    

  • daklib/daklog.py


  • Reply to: