summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-11-05 20:09:35 +0100
committerSebastian Thiel <byronimo@gmail.com>2009-11-05 20:09:35 +0100
commit46c9a0df4403266a320059eaa66e7dce7b3d9ac4 (patch)
tree7829c074049295b869db1bdcf4f457ebefea62b7
parenta67bf61b5017e41740e997147dc88282b09c6f86 (diff)
downloadgitpython-46c9a0df4403266a320059eaa66e7dce7b3d9ac4.tar.gz
cmd: added clear_cache method now used by test repo decorators to be sure persistent commands are killed before trying to remove the directory. Unfortunately, it still claims someone has opened the file. handle.exe does not show anyone, so what is happening here ? Is it just a windows odity ? If nothing helps I could just keep the temp data, but lets do some more testing first
-rw-r--r--TODO10
-rw-r--r--lib/git/cmd.py15
-rw-r--r--test/testlib/helper.py4
3 files changed, 25 insertions, 4 deletions
diff --git a/TODO b/TODO
index 15847102..d5971f2d 100644
--- a/TODO
+++ b/TODO
@@ -11,9 +11,13 @@ General
a sha or ref unless cat-file is used where it must be a sha
* Overhaul command caching - currently its possible to create many instances of
the std-in command types, as it appears they are not killed when the repo gets
- deleted. A clear() method could already help to allow long-running programs
- to remove cached commands after an idle time.
-
+ deleted.
+* git command on windows may be killed using the /F options which probably is like
+ SIGKILL. This is bad as the process might be doing something, leaving the resource
+ locked and/or in an inconsistent state. Without the /F option, git does not terminate
+ itself, probably it listens to SIGINT which is not sent by TASKKILL. We can't really
+ help it, but may be at some point git handles windows signals properly.
+
Object
------
* DataStream method should read the data itself. This would be easy once you have
diff --git a/lib/git/cmd.py b/lib/git/cmd.py
index 97d6613d..6d712ca9 100644
--- a/lib/git/cmd.py
+++ b/lib/git/cmd.py
@@ -17,7 +17,7 @@ execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output',
'output_stream' )
extra = {}
-# NOTE: Execution through a shell appears to be slightly faster, but in fact
+# NOTE: Execution through a shell on windows appears to be slightly faster, but in fact
# I consider it a problem whenever complex strings are passed and *interpreted*
# by the shell beforehand. This can cause great confusion and reduces compatability
# between the OS which is why the shell should not be used ( unless it does not work
@@ -401,3 +401,16 @@ class Git(object):
cmd.stdout.read(1) # finishing newlines
return (hexsha, typename, size, data)
+
+ def clear_cache(self):
+ """
+ Clear all kinds of internal caches to release resources.
+
+ Currently persistent commands will be interrupted.
+
+ Returns
+ self
+ """
+ self.cat_file_all = None
+ self.cat_file_header = None
+ return self
diff --git a/test/testlib/helper.py b/test/testlib/helper.py
index 27c2b3d9..5599f05e 100644
--- a/test/testlib/helper.py
+++ b/test/testlib/helper.py
@@ -82,6 +82,7 @@ def with_bare_rw_repo(func):
try:
return func(self, rw_repo)
finally:
+ rw_repo.git.clear_cache()
shutil.rmtree(repo_dir)
# END cleanup
# END bare repo creator
@@ -107,6 +108,7 @@ def with_rw_repo(working_tree_ref):
try:
return func(self, rw_repo)
finally:
+ rw_repo.git.clear_cache()
shutil.rmtree(repo_dir)
# END cleanup
# END rw repo creator
@@ -179,6 +181,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
try:
return func(self, rw_repo, rw_remote_repo)
finally:
+ rw_repo.git.clear_cache()
+ rw_remote_repo.git.clear_cache()
shutil.rmtree(repo_dir)
shutil.rmtree(remote_repo_dir)
# END cleanup