def _release_resource(resource_id): """ Do not queue this task yourself, but always use the _queue_release_resource() task instead. Please see the docblock on that function for an explanation. When a resource-reserving task is complete, this method must be called with the resource_id so that the we know when it is safe to unmap a resource_id from its given queue name. :param resource_id: The resource that is no longer in use :type resource_id: basestring """ try: reserved_resource = ReservedResource(resource_id) reserved_resource.decrement_num_reservations() # Now we need to decrement the AvailabeQueue that the reserved_resource was using. If the # ReservedResource does not exist for some reason, we won't know its assigned_queue, but # these next lines won't execute anyway. available_queue = AvailableQueue(reserved_resource.assigned_queue) available_queue.decrement_num_reservations() except DoesNotExist: # If we are trying to decrement the count on one of these obejcts, and they don't exist, # that's OK pass