Wait for threads to exit after stopping model installer/downloader #6014
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR causes the model_installer and download_queue
stop()
methods to block until their worker threads have exited. Previouslystop()
returned immediately.This fix addresses an issue in the model installer unit test, where the installer is created and torn down in a pytest fixture. Because a new installer was created immediately after the previous installer was torn down, it was possible for the old installer’s threads to intermix with the current ones, causing unpredictable results. This may fix the sporadic hangs and timeouts observed in the model installer unit test.
The downside of this is that the
test_model_install
andtest_download
unit tests now run noticeably slower than they used to due to waiting for the threads to exit. The alternative, of scoping the install fixture to the module or session level, is undesirable because we want each test function to start out with a clean install directory and registry.Related Issues / Discussions
See discord https://discord.com/channels/1020123559063990373/1149513695567810630/1219777315148664882
QA Instructions
If this PR fixes the problem, we will no longer see sporadic timeouts during unit testing. It is a very hard bug to reproduce, however, so time will tell.
Merge Plan
Merge when approved.
Checklist