-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DATAGO-93385/DATAGO-93864/Gracefully Terminate the Connector #85
DATAGO-93385/DATAGO-93864/Gracefully Terminate the Connector #85
Conversation
Please mark whether you used Copilot to assist coding in this PR
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes:
-
Added a try-exception around the connection logic.
-
Added the below logics to 1) wait till the connection is established 2) raise and exception and exit when a signal is triggered.
# wait for the connection to complete while not self.stop_signal.is_set(): done, _ = concurrent.futures.wait([result], timeout=0.1) if done: break # disconnect and raise an exception if the stop signal is set if self.stop_signal.is_set(): log.error(f"{self.error_prefix} Stopping connection attempt") self.disconnect() raise KeyboardInterrupt("Stopping connection attempt")
src/solace_ai_connector/main.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes:
- Added a signal handler to trigger an exception. These exceptions can break the app.run() in any condition (either creating or running the workflow) and consequently calls the Shutdown() method (line #130) to stop and cleanup everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes:
- Added exception handlers and removed duplicate stop and cleanup, as they are called by Shutdown method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a suggestion
The rest looks good
…-gracefully-when-the-broker-is-not-connected-initially
SonarQube Quality Gate |
What is the purpose of this change?
The connector does not terminate by a signal when the broker is attempting to connect. The root cause of the problem is that the connector attempts to establish a connection while creating a workflow. So, if it cannot connect, it cannot make the workflow. The current signal can terminate a component; however, no component is created in the above situation.
How is this accomplished?
Added some exception handling to the workflow creation logic and added a signal handling method to trigger an exception.
Anything reviews should focus on/be aware of?
The reviewer can focus on the exception handling solution and any possible edge cases.