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

Close all opened dulwich repo objects #139

Merged
merged 4 commits into from
Nov 23, 2021

Conversation

aplaice
Copy link
Collaborator

@aplaice aplaice commented Aug 17, 2021

Otherwise, especially on Windows, we might end up with locked files.

Fix #138.

dulwich's pull can operate either on paths or on dulwich repo objects. Since it's using open_repo_closing internally, if it (and hence open_repo_closing) are passed a path, the associated repo object will be automatically closed after use, so we don't have to worry about anything. (If they're passed an already existing "repo object", as we had been doing previously, then, internally, they use _noop_context_manager(), instead of closing() and the repo object isn't closed.)

(The above is true for current dulwich master (80bffaca1dfe59a5ba57a045f3ce7122227a7647) — see dulwich/porcelain.py.)


For the record, I built the dist/ folder (for testing purposes) with:

pip3 install --upgrade --no-binary :all: -r <(pipenv lock -r | sed -E -e "s/(^dulwich==.+$)/\1 --global-option=--pure/" -e "s/^(pyyaml==.+$)/\1 --global-option=--without-libyaml/")  --target crowd_anki/dist

due to issues caused by the recent upgrade of pyyaml. EDIT: the issues were due to how I had installed python3.7, and are not universal!

Otherwise, especially on Windows, we might end up with locked files.

Fix Stvad#138.

dulwich's pull can operate either on paths or on dulwich repo objects.
Since it's using `open_repo_closing` internally, if it (and hence
`open_repo_closing`) are passed a path, the associated repo object
will be automatically closed after use, so we don't have to worry
about anything.  (If they're passed an already existing "repo object",
as we had been doing previously, then, internally, they use
`_noop_context_manager()`, instead of `closing()` and the repo object
isn't closed.)

(The above is true for current dulwich master
(`80bffaca1dfe59a5ba57a045f3ce7122227a7647`) — see
`dulwich/porcelain.py`.)
(We're already using errstream, which is the intended replacement for outstream.)
Newer versions of pyfunctional use poetry, which results in the
"no-binary" build hanging.

This should be circumventable, but it's lower priority.
@aplaice aplaice force-pushed the close_dulwich_repos branch from 802a193 to fd0296f Compare November 23, 2021 16:24
@aplaice
Copy link
Collaborator Author

aplaice commented Nov 23, 2021

Given that my manual testing (from several months ago) and the newly added test (#150) both show that this PR resolves the import issue, I think that this is safe to merge.

@aplaice aplaice merged commit e253603 into Stvad:master Nov 23, 2021
@aplaice aplaice deleted the close_dulwich_repos branch November 23, 2021 16:30
@aplaice aplaice linked an issue Nov 23, 2021 that may be closed by this pull request
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.

Error in updating deck by importing from Github URL (Anki 2.1.46) Import from Git hub fail: (Anki 2.1.30)
1 participant