Safely stop agent heartbeat and handle Disconnected exception#419
Merged
BrianJKoopman merged 3 commits intomainfrom Jan 17, 2025
Merged
Safely stop agent heartbeat and handle Disconnected exception#419BrianJKoopman merged 3 commits intomainfrom
BrianJKoopman merged 3 commits intomainfrom
Conversation
jlashner
approved these changes
Jan 16, 2025
Contributor
jlashner
left a comment
There was a problem hiding this comment.
Thanks Brian, these changes seem to me like they should help!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a check to make sure the heartbeat is still running before trying to stop the looping call,
self.heartbeat_call. We also add exception handling for theautobahn.exception.Disconnectedexception we've been seeing occasionally when an agent loses its connection to the crossbar server and goes to flush its feed buffer.Motivation and Context
If an agent loses its connection to the crossbar server the heartbeat looping call might crash before it is stopped when
onLeave()is triggered. This hits an assertion error in twisted.Additionally, when the agent goes to flush its buffer by publishing any data it has that publish call will fail with an
autobahn.exception.Disconnectedexception. We were already handling theTransportLostexception, so we just addDisconnected.An example of hitting both of these at the same time can be see in #417.
Resolves #417.
How Has This Been Tested?
I haven't been able to reproduce #417 locally. I've tried by running a small ocs network with the registry and several fake data agents. I then cycle the crossbar server over and over again, hoping to hit the exception just right. Cycling a couple dozen times never hit it.
I'm still going to try to think of a way to reproduce this, but wanted to get the PR open.
Types of changes
Checklist: