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

Refactor logic for processing requirements.txt so all I/O operations happen in a single function #69

Merged
merged 2 commits into from
Oct 31, 2020

Conversation

raman325
Copy link
Contributor

@raman325 raman325 commented Oct 31, 2020

installed_version also does IO from #68, this moves it to an executor job. Thanks @bdraco for catching this!

@raman325 raman325 changed the title Run installed_version as executor job Run installed_version in executor job Oct 31, 2020
@craigbarratt
Copy link
Member

craigbarratt commented Oct 31, 2020

Good catch. However, I'd rather not run a new thread inside the loop for every package.

Perhaps most of the code can move into load_all_requirement_lines, and it just returns a list of packages that need to be installed. Then install_requirements just calls hass.async_add_executor_job and async_process_requirements. That way we only run one thread at startup or reload, not 1 + the number of lines in all the requirements files.

If you take that approach, you'll also want to rename load_all_requirement_lines, since it does more than that.

@raman325 raman325 changed the title Run installed_version in executor job Refactor logic for processing requirements.txt so all I/O operations happen in a single function Oct 31, 2020
@craigbarratt
Copy link
Member

Nice! This looks great, and tests look good too.

@craigbarratt craigbarratt merged commit 60232a3 into custom-components:master Oct 31, 2020
@raman325 raman325 deleted the install_packages branch November 1, 2020 02:45
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.

None yet

2 participants