mediakit 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mediakit/utils/process_runner.rb +33 -18
- data/lib/mediakit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7435ac359f8e6bd85841a8e6d9aa40b4f9984250
|
4
|
+
data.tar.gz: f73d0dcf7d9b077eaf702b46844a5f255ca5f94f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 991f5cf8db3564fe37f20a61601318bbf120cf0e66100402850adac03b4cc429fb78ed09ce67cca7e02cfad5c53f3c3da504806c39fb75217e10ffe11a48b520
|
7
|
+
data.tar.gz: 66356ffb1faccd86054c39f5680356bc3fadf9e606e3054dd2eb4680e9ebf2a36fa65ff7f8bee8bc69887d31ec6824e9c3adbf312f82c86c032f81e4d07570d4
|
@@ -32,29 +32,44 @@ module Mediakit
|
|
32
32
|
command = build_command(bin, *args)
|
33
33
|
exit_status = nil
|
34
34
|
begin
|
35
|
-
stdin, stdout, stderr,
|
35
|
+
stdin, stdout, stderr, wait_thread = Open3.popen3(command)
|
36
36
|
stdin.close
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
wait_thr.join
|
43
|
-
exit_status = (wait_thr.value.exitstatus == 0)
|
44
|
-
rescue Timeout::Error => error
|
45
|
-
force_kill_process(pid)
|
46
|
-
raise(error)
|
47
|
-
ensure
|
48
|
-
out_watcher.close unless out_watcher && out_watcher.closed?
|
49
|
-
err_watcher.close unless err_watcher && err_watcher.closed?
|
50
|
-
timer.detach if timer
|
51
|
-
loop_thread.join if loop_thread
|
52
|
-
end
|
37
|
+
output, error_output, exit_status = if @timeout
|
38
|
+
wait_with_timeout(stdout, stderr, wait_thread)
|
39
|
+
else
|
40
|
+
wait_without_timeout(stdout, stderr, wait_thread)
|
41
|
+
end
|
53
42
|
rescue Errno::ENOENT => e
|
54
43
|
raise(CommandNotFoundError, "Can't find command - #{command}, #{e.meessage}")
|
55
44
|
end
|
56
45
|
|
57
|
-
[
|
46
|
+
[output, error_output, exit_status]
|
47
|
+
end
|
48
|
+
|
49
|
+
def wait_without_timeout(stdout, stderr, wait_thread)
|
50
|
+
wait_thread.join
|
51
|
+
exit_status = (wait_thread.value.exitstatus == 0)
|
52
|
+
[stdout.read, stderr.read, exit_status]
|
53
|
+
end
|
54
|
+
|
55
|
+
def wait_with_timeout(stdout, stderr, wait_thread)
|
56
|
+
begin
|
57
|
+
loop = Coolio::Loop.new
|
58
|
+
timer, out_watcher, err_watcher = setup_watchers(loop, stdout, stderr)
|
59
|
+
loop_thread = Thread.new { loop.run }
|
60
|
+
wait_thread.join
|
61
|
+
exit_status = (wait_thread.value.exitstatus == 0)
|
62
|
+
rescue Timeout::Error => error
|
63
|
+
force_kill_process(wait_thread.pid)
|
64
|
+
raise(error)
|
65
|
+
ensure
|
66
|
+
out_watcher.close if out_watcher && !out_watcher.closed?
|
67
|
+
err_watcher.close if err_watcher && !err_watcher.closed?
|
68
|
+
timer.detach if timer && timer.attached?
|
69
|
+
loop_thread.join if loop_thread
|
70
|
+
end
|
71
|
+
|
72
|
+
[out_watcher.data, err_watcher.data,exit_status]
|
58
73
|
end
|
59
74
|
|
60
75
|
def build_command(bin, *args)
|
data/lib/mediakit/version.rb
CHANGED