Agent: Use a finally clause to ensure singleton is always unlocked

This commit is contained in:
Mike Salvatore 2022-09-07 19:45:12 -04:00
parent 6c2cab9950
commit 1d58ce36e7
1 changed files with 2 additions and 1 deletions

View File

@ -415,11 +415,12 @@ class InfectionMonkey:
).send() # Signal the server (before closing the tunnel)
self._close_tunnel()
self._singleton.unlock()
except Exception as e:
logger.error(f"An error occurred while cleaning up the monkey agent: {e}")
if deleted is None:
InfectionMonkey._self_delete()
finally:
self._singleton.unlock()
logger.info("Monkey is shutting down")