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

Added check to ensure QThreads are finished before destroying them #245

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

collin-volk
Copy link

This is a fix for issue #244. In async_threads (and also async, although I couldn't find that being used anywhere) threads are destroyed in the finish slot of the AsyncThreads class. This slot is called when the finished signal is emitted by one of the threads at the end of their run function and leads to a race condition where the thread might not truly finish running before del is called on it. Adding a while loop checking the QThread isFinished function before destroying the thread ensures that the thread has actually finished running.

On a related note, QThread already has a finished signal that gets emitted when the thread actually finishes. Unfortunately, this signal doesn't include any information on what thread finished so it can't be used to perform the cleanup needed in AsyncThreads. In any case, it might be a good idea to rename the finished signal in AsyncThread to something like completed to avoid any confusion with the QThread finished signal.

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.

1 participant