Skip to content

Fix: Reuse PairedTransmitter outside loop to prevent repeated ZMQ socket creation (#268)#294

Merged
pradeeban merged 1 commit intoControlCore-Project:devfrom
GaneshPatil7517:fix/zmq-transmitter-lifecycle
Feb 13, 2026
Merged

Fix: Reuse PairedTransmitter outside loop to prevent repeated ZMQ socket creation (#268)#294
pradeeban merged 1 commit intoControlCore-Project:devfrom
GaneshPatil7517:fix/zmq-transmitter-lifecycle

Conversation

@GaneshPatil7517
Copy link
Copy Markdown
Contributor

@GaneshPatil7517 GaneshPatil7517 commented Feb 12, 2026

Hey pradeeban,

Fixes #268.

In 0mq/funcall.py, PairedTransmitter was being created and destroyed inside every loop iteration. This resulted in unnecessary ZMQ socket creation, extra thread overhead, and in some cases port rebinding problems due to the TIME_WAIT state.

To fix this, the transmitter initialization and background thread start are moved outside the loop so they are created only once. A try/finally block is also added to ensure the transmitter is properly cleaned up after the loop finishes.

This improves performance and avoids potential socket exhaustion while keeping the existing behavior unchanged.

Copilot AI review requested due to automatic review settings February 12, 2026 12:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the resource lifecycle in the 0mq/funcall.py ZMQ client loop by reusing a single PairedTransmitter instance instead of creating/tearing it down every iteration, avoiding repeated socket/thread churn.

Changes:

  • Instantiate PairedTransmitter once before the simulation loop.
  • Start background sync once and stop it once using a try/finally to guarantee cleanup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pradeeban pradeeban merged commit d3b9f55 into ControlCore-Project:dev Feb 13, 2026
11 of 12 checks passed
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