Launches git cat-file processes which never die #1209
-
I'm using this package to clone many repos. It's part of a utility which clones all repos under a GitLab group. cmd = self._get_persistent_cmd("cat_file_header", "cat_file", batch_check=True)
# and ...
cmd = self._get_persistent_cmd("cat_file_all", "cat_file", batch=True) I guess emphasis on persistent right? Gather, count, and look at the procs
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I think it's good to start off this discussion with a reference to known resource leakage and ways to fix it. Something worth investigating here is if somehow the same repository is creating multiple git commands, leaving 'zombies' of previous invocation as process children or worse, detached from its parent process (python). If you think that this is probably not the case then it's worth trying to explicitly calling the destructor on a |
Beta Was this translation helpful? Give feedback.
-
Create and reuse should be the way to do it.
Would you mind adding a note about the context manager support for repos to the readme resource leakage section? It seems like it would be helpful if it was more prominent.
…Sent from my iPhone
On Mar 31, 2021, at 11:31 PM, Eric L. Frederich ***@***.***> wrote:
I noticed a repo acts as a context manager via __enter__ and __exit__. In fact, __exit__ calls self.close() same as the __del__() you recommended calling.
Question... is it safe to re-use existing repo objects more than once or should I create a new one each time?
Create and re-use just one Repo object
for path in paths:
repo = git.Repo(some_path)
with repo:
repo.some_operation()
# ... other code
with repo:
repo.another_operation()
Create Repo objects as needed
for path in paths:
with git.Repo(some_path) as repo:
repo.some_operation()
# ... other code
with git.Repo(some_path) as repo:
repo.another_operation()
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Beta Was this translation helpful? Give feedback.
I think it's good to start off this discussion with a reference to known resource leakage and ways to fix it.
Something worth investigating here is if somehow the same repository is creating multiple git commands, leaving 'zombies' of previous invocation as process children or worse, detached from its parent process (python).
If you think that this is probably not the case then it's worth trying to explicitly calling the destructor on a
Repo
instance once you are done with it.