Skip to content
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

refactor(robot-server): Interact with Paho from a single thread #16078

Merged
merged 5 commits into from
Aug 21, 2024

Conversation

SyntaxColoring
Copy link
Contributor

@SyntaxColoring SyntaxColoring commented Aug 20, 2024

Overview

Closes EXEC-685. See that ticket for explanation.

Test Plan and Hands on Testing

  • Push this to a real robot, click around, and make sure notifications are still basically working.

Changelog

  • Remove all multithreaded access to Paho. We should now exclusively interact with it through robot-server's main FastAPI thread.
  • A few other minor refactors. See the commit messages for details.

Review requests

Double-check my understanding of how Paho works. If I'm wrong about its publish() method being non-blocking, this risks stalling all of robot-server. For example, if some Paho buffer fills up, robot-server will stop responding to GET /health requests until it's drained.

Risk assessment

Low-ish, but see review requests.

@SyntaxColoring SyntaxColoring changed the title refactor(robot-server): Interface with MQTT from a single thread refactor(robot-server): Interact with Paho from a single thread Aug 21, 2024
@SyntaxColoring SyntaxColoring requested review from mjhuff and a team August 21, 2024 16:33
@SyntaxColoring SyntaxColoring marked this pull request as ready for review August 21, 2024 16:33
@SyntaxColoring SyntaxColoring requested a review from a team as a code owner August 21, 2024 16:33
Copy link
Contributor

@mjhuff mjhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for digging into this (and fixing some of my sloppier Python work)!

It's strange to me that the major MQTT library for Python doesn't document its publish behavior as well as we'd expect. From what I can tell, these changes are safe. I think merging this kind of networking stuff into edge as early as possible into the next dev cycle is the best move.

"""Intended to be used by endpoint functions as a FastAPI dependency."""
notification_client = _notification_client_accessor.get_from(app_state)
assert (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Copy link
Contributor

@TamarZanzouri TamarZanzouri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code changes lgtm!

@SyntaxColoring SyntaxColoring merged commit b31700d into edge Aug 21, 2024
13 checks passed
@SyntaxColoring SyntaxColoring deleted the notifications_infra_refactors branch August 21, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants