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

[Git][ftp-team/dak][master] Close the lock_fd handle before calling cronscript



Title: GitLab

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

Commits:

1 changed file:

Changes:

  • dak/new_security_install.py
    ... ... @@ -89,27 +89,24 @@ def sudo(arg, fn, exit):
    89 89
     def do_Approve(): sudo("A", _do_Approve, True)
    
    90 90
     def _do_Approve():
    
    91 91
         print "Locking unchecked"
    
    92
    -    lock_fd = os.open('/srv/security-master.debian.org/lock/unchecked.lock', os.O_RDWR | os.O_CREAT)
    
    93
    -    while True:
    
    94
    -        try:
    
    95
    -            fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    
    96
    -            break
    
    97
    -        except IOError as e:
    
    98
    -            if e.errno in (errno.EACCES, errno.EAGAIN):
    
    99
    -                print "Another process keeping the unchecked lock, waiting."
    
    100
    -                time.sleep(10)
    
    101
    -            else:
    
    102
    -                raise
    
    103
    -
    
    104
    -    # 1. Install accepted packages
    
    105
    -    print "Installing accepted packages into security archive"
    
    106
    -    for queue in ("embargoed",):
    
    107
    -        spawn("dak process-policy {0}".format(queue))
    
    108
    -
    
    109
    -    # Unlock, the cronscript coming up locks itself where needed.
    
    110
    -    fcntl.flock(lock_fd, fcntl.LOCK_UN)
    
    111
    -
    
    112
    -    # 3. Run all the steps that are needed to publish the changed archive
    
    92
    +    with os.fdopen(os.open('/srv/security-master.debian.org/lock/unchecked.lock', os.O_CREAT | os.O_RDWR ), 'w') as lock_fd:
    
    93
    +        while True:
    
    94
    +            try:
    
    95
    +                fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    
    96
    +                break
    
    97
    +            except IOError as e:
    
    98
    +                if e.errno in (errno.EACCES, errno.EAGAIN):
    
    99
    +                    print "Another process keeping the unchecked lock, waiting."
    
    100
    +                    time.sleep(10)
    
    101
    +                else:
    
    102
    +                    raise
    
    103
    +
    
    104
    +        # 1. Install accepted packages
    
    105
    +        print "Installing accepted packages into security archive"
    
    106
    +        for queue in ("embargoed",):
    
    107
    +            spawn("dak process-policy {0}".format(queue))
    
    108
    +
    
    109
    +    # 2. Run all the steps that are needed to publish the changed archive
    
    113 110
         print "Doing loadsa stuff in the archive, will take time, please be patient"
    
    114 111
         os.environ['configdir'] = '/srv/security-master.debian.org/dak/config/debian-security'
    
    115 112
         spawn("/srv/security-master.debian.org/dak/config/debian-security/cronscript unchecked-dinstall")
    


  • Reply to: