Merge lp:~chipaca/unity-lens-video/no-moar-zombies into lp:unity-lens-video

Proposed by John Lenton
Status: Merged
Merged at revision: 55
Proposed branch: lp:~chipaca/unity-lens-video/no-moar-zombies
Merge into: lp:unity-lens-video
Diff against target: 66 lines (+19/-11)
1 file modified
src/unity-lens-video (+19/-11)
To merge this branch: bzr merge lp:~chipaca/unity-lens-video/no-moar-zombies
Reviewer Review Type Date Requested Status
Unity Videos lens Pending
Review via email: mp+94671@code.launchpad.net

Description of the change

Gets rid of the zombies, via switching from subprocess to GLib.spawn_sync and spawn_async.

The zombies issue could've been fixed with waitpid, but then moving to vala would've been harder. This way it's GLibs all the way down.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-lens-video'
2--- src/unity-lens-video 2012-02-24 08:26:51 +0000
3+++ src/unity-lens-video 2012-02-26 00:07:21 +0000
4@@ -22,7 +22,6 @@
5 import locale
6 import os
7 import sys
8-import subprocess
9 from zeitgeist import client, datamodel
10
11 #pylint: disable=E0611
12@@ -176,14 +175,14 @@
13
14 def update_results_model(self, search, model, cat):
15 """Check for the existence of the cache folder, create it if needed,
16- the run the search method."""
17+ and run the search method."""
18 if not Gio.file_new_for_path(CACHE).query_exists(None):
19 Gio.file_new_for_path(CACHE).make_directory(None)
20 if FOLDER != HOME_FOLDER:
21 try:
22- subprocess.Popen(['updatedb',
23- '-o', CACHE+'/'+DB, '-l', '0', '-U', FOLDER])
24- except (subprocess.CalledProcessError):
25+ GLib.spawn_async(['/usr/bin/updatedb', '-o', CACHE+'/'+DB,
26+ '-l', '0', '-U', FOLDER])
27+ except GLib.GError:
28 print "Can't create the database, will retry."
29
30 result_sets = []
31@@ -220,10 +219,19 @@
32
33 if self.is_file(CACHE+'/'+DB):
34 try:
35- results = subprocess.check_output(
36- ['locate', '-id', CACHE+'/'+DB, FOLDER+'*'+search+'*' ])
37- except (subprocess.CalledProcessError):
38+ results = GLib.spawn_sync(None,
39+ ['/usr/bin/locate',
40+ '-id', CACHE+'/'+DB,
41+ FOLDER+'*'+search+'*' ],
42+ None, 0, None, None)
43+ except GLib.GError:
44 results = None
45+ else:
46+ # spawn_sync returns bool, stdout, stderr, exit_status
47+ if results[3] == 0:
48+ results = results[1]
49+ else:
50+ results = None
51 else:
52 results = None
53 if results:
54@@ -328,9 +336,9 @@
55 Q.remove(process)
56 if len(Q) < Q_MAX:
57 try:
58- p = subprocess.Popen(['totem-video-thumbnailer',
59- video_path, icon_check])
60- Q.append(p.pid)
61+ p = GLib.spawn_async(['/usr/bin/totem-video-thumbnailer',
62+ video_path, icon_check])
63+ Q.append(p[0])
64 if self.is_file(icon_check):
65 icon_path = icon_check
66 except:

Subscribers

People subscribed via source and target branches