I am trying to handle a failure on fabric, but the example I saw in the docs was too localized to my liking. I need to perform rollback actions if any of several actions fail. Then I tried to use contexts to handle it, for example:
@_contextmanager
def failwrapper():
with settings(warn_only=True):
result = yield
if result.failed:
rollback()
abort("********* Failed to execute deploy! *********")
And then
@task
def deploy():
with failwrapper():
updateCode()
migrateDb()
restartServer()
Unfortunately, when one of these tasks fails, I don't get anything on result.
Is there any way to do this? Or is there another way to deal with such situations?
source
share