exclusive_resources: use set remove instead of discard

If the release function cannot find a resource in the allocation
pool, it should raise an error.

Change-Id: Ieffd547f5c08fbe56289c99dc0384e7bd8a8f85b
This commit is contained in:
IWAMOTO Toshihiro
2016-07-06 11:56:12 +09:00
parent 77cdddb055
commit 66f01fd944

View File

@@ -88,7 +88,7 @@ class ResourceAllocator(object):
@utils.synchronized('resource_allocator', external=True, lock_path='/tmp')
def release(self, resource):
allocations = self._get_allocations()
allocations.discard(resource)
allocations.remove(resource)
if allocations:
self._write_allocations(allocations)
else: # Clean up the file if we're releasing the last allocation