Skip to content

Commit

Permalink
Make sure we cleanup even if fails in example
Browse files Browse the repository at this point in the history
  • Loading branch information
cderici committed Dec 2, 2021
1 parent f307098 commit 444a66b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/deploy_local_file_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async def main():
# connect to current model with current user, per Juju CLI
await model.connect()

application = None
try:
print('Deploying local-charm')
base_dir = Path(__file__).absolute().parent.parent
Expand All @@ -33,6 +34,11 @@ async def main():

print('Removing Charm')
await application.remove()
except Exception as e:
print(e)
if application:
await application.remove()
await model.disconnect()
finally:
print('Disconnecting from model')
await model.disconnect()
Expand Down

0 comments on commit 444a66b

Please sign in to comment.