diff options
| author | P. Christeas <p_christ@hol.gr> | 2010-12-09 13:26:07 +0200 |
|---|---|---|
| committer | P. Christeas <p_christ@hol.gr> | 2010-12-09 13:26:07 +0200 |
| commit | 18a5ade8fd72edcbca951240d4071f2a8fccaa48 (patch) | |
| tree | c2dddec6d6f11989247ea794b7c465f34ffc48c0 /addons/document/content_index.py | |
| parent | 9023049b49a2d072ad16ebf76526c1ecb34d9433 (diff) | |
document: fix content indexer's handling of the "file" command
Content indexer spawns the *nix "file" command in an attempt to determine
the type of arbitrary files. The way we have fetched the stdout of the
child process had been flawed, leaving a zombie process for every file
scanned. It was not a matter of closing the file descriptors, rather an
issue of cleaning up the child process.
bzr revid: p_christ@hol.gr-20101209112607-psu98d0h2e7xqwu7
Diffstat (limited to 'addons/document/content_index.py')
| -rw-r--r-- | addons/document/content_index.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/addons/document/content_index.py b/addons/document/content_index.py index 6d49a29873f..72cb8f6e163 100644 --- a/addons/document/content_index.py +++ b/addons/document/content_index.py @@ -165,11 +165,9 @@ class contentIndex(object): os.write(fd, content) os.close(fd) - fp = Popen(['file','-b','--mime',fname], shell=False, stdout=PIPE).stdout - try: - result = fp.read() - finally: - fp.close() + pop = Popen(['file','-b','--mime',fname], shell=False, stdout=PIPE) + (result, _) = pop.communicate() + mime2 = result.split(';')[0] self.__logger.debug('File gave us: %s', mime2) # Note that the temporary file still exists now. |
