Skip to content

Commit

Permalink
Fix shutdown plugin on timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
1maple1 committed Aug 19, 2024
1 parent de33d39 commit 9e5a394
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions brewtils/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,21 @@ def run(self):
try:
self._startup()
self._logger.info("Plugin %s has started", self.unique_name)

try:
# Need the timeout param so this works correctly in Python 2
while not self._shutdown_event.wait(timeout=0.1):
pass
except KeyboardInterrupt:
self._logger.debug("Received KeyboardInterrupt - shutting down")
except Exception as ex:
self._logger.exception("Exception during wait, shutting down: %s", ex)

self._shutdown()
except PluginValidationError:
self._shutdown(status="ERROR")

try:
# Need the timeout param so this works correctly in Python 2
while not self._shutdown_event.wait(timeout=0.1):
pass
except KeyboardInterrupt:
self._logger.debug("Received KeyboardInterrupt - shutting down")
except Exception as ex:
self._logger.exception("Exception during wait, shutting down: %s", ex)

self._shutdown()
self._logger.info("Plugin %s has terminated", self.unique_name)
finally:
self._logger.info("Plugin %s has terminated", self.unique_name)

@property
def client(self):
Expand Down

0 comments on commit 9e5a394

Please sign in to comment.