Skip to content

Conversation

@ToveRumar
Copy link
Contributor

@ToveRumar ToveRumar commented Jun 13, 2025

In this PR I added functionality so that the paramupdater thread will start when a connection is initiated, not when the Param object is created.
This makes the thread only live while there is a connection.

Also make some other threads daemons so they close when main program closes.

@ToveRumar ToveRumar requested a review from gemenerik June 13, 2025 13:18
@ataffanel ataffanel requested a review from Copilot June 18, 2025 08:27
Copy link

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 ensures that the ParamUpdater thread is started only upon establishing a connection and that several threads are set as daemon so they automatically close with the main program.

  • The ParamUpdater is now initialized in the connection callback instead of object creation.
  • Several threads (including Radiodriver and IncomingPacketHandler) are explicitly marked as daemon.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
cflib/crtp/radiodriver.py The thread now sets self.daemon=True in its constructor.
cflib/crazyflie/param.py Moved ParamUpdater thread initialization to connection time and updated error handling.
cflib/crazyflie/init.py Updated the IncomingPacketHandler to use a named thread and set as daemon.
Comments suppressed due to low confidence (1)

cflib/crazyflie/param.py:314

  • Consider using a more specific exception type (e.g., RuntimeError) to better convey the error context in production code.
            raise Exception('Param updater not initialized, did you call open_connection?')

Copy link
Member

@ataffanel ataffanel left a comment

Choose a reason for hiding this comment

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

LGTM, it is a nice step forward to clean the threading situation!

@ataffanel ataffanel merged commit 3f8fd51 into master Jun 18, 2025
1 check passed
@ataffanel ataffanel deleted the toverumar/test_pram_threads branch June 18, 2025 08:29
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