• Guido Trotter's avatar
    LockSet: make acquire() able to get the whole set · 3b7ed473
    Guido Trotter authored
    This new functionality makes it possible to acquire a whole set, by passing
    "None" to the acquire() function as the list of elements. This will avoid new
    additions to the set, and then acquire all the current elements. The list of
    all elements acquired will be returned at the end.
    
    Deletions can still happen during the acquire process and we'll deal with it by
    just skipping the deleted elements: it's effectively as if they were deleted
    before we called the function. After we've finished though we hold all the
    elements, so no more deletes can be performed before we release them.
    
    Any call to release() will then first of all release the "set-level" lock if
    we're holding it, and then all or some of the locks we have.
    
    Some new tests checks that this feature works as intended.
    
    Reviewed-by: imsnah
    
    3b7ed473
ganeti.locking_unittest.py 24.8 KB