def _upgrade_timer(self): lock = DocumentLock('wstore_resource', self._to_downgrade.pk, 'asset') lock.wait_document() # Refresh asset info asset = Resource.objects.get(pk=self._to_downgrade.pk) # If the asset is in upgrading state when the timer ends, rollback is called if asset.state == 'upgrading': downgrade_asset(asset) lock.unlock_document()
def rollback_method(asset): if asset.product_id == product_spec['id'] and asset.state == 'upgrading': downgrade_asset(asset)