Skip to content

Conversation

@ToveRumar
Copy link
Contributor

There where some threads (param related) that would never close.
They would even keep their Crazyflie object alive forever. This would slow down performance over time.

Fix this by making sure the threads exit by sending a None object to the queue and setting the should_close flag.

Previously we where counting on this behavior and never created new thread objects upon reconnect of the same crazyflie object. So I added creation of the thread objects if there is no object (i.e the connection was closed).
This way you can re-use the same Crazyflie object if you want (this is done in testing), or throw it away and create a new object. Both of these will create the correct number of threads.

Did some cleanup by naming the threads for easier debugging. I also made sure the callbacks in param.py does not modify the original message. This could cause unknown side effects.

ToveRumar added 3 commits June 4, 2025 14:45
The threads where never actually exited since they would hang waiting for next message in the queue for ever.

To fix this we send a None message to unlock the queue.
The _should_close flag (was created but not used before) should be used to actually close the thread
The param callback modifyed the original packet.
The owner of the packet is not the param thread but the caller, and its better not to
modify it. The caller might call several callbacks after and they should get the original
@ToveRumar ToveRumar requested a review from gemenerik June 4, 2025 13:20
@gemenerik gemenerik merged commit 1121a10 into master Jun 5, 2025
1 check passed
@gemenerik gemenerik deleted the toverumar/Fix_param_thread_close branch June 5, 2025 08:14
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