process_executer 1.0.2 → 1.1.0
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/CHANGELOG.md +8 -0
- data/README.md +9 -1
- data/lib/process_executer/status.rb +44 -0
- data/lib/process_executer/version.rb +1 -1
- data/lib/process_executer.rb +4 -3
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f568a98075e32879207b26949346e4181eed2d2432c9665e84ddb015d5ded96c
|
4
|
+
data.tar.gz: bcc6f74e77155a251d4ad561495f6edb1b6cf95bccc23b7de7322a0897d4a0af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fc886fade1e486d6acb6c32864a469a6d77700c596dd15a47c4e59e440bfda06b3a1ca506fc4a9be8f7d3bea831525329e735d9cb30d5c01d48395571f9164c
|
7
|
+
data.tar.gz: cab6c4b4d5d1761ac46df3aff8c02c44fed93d071bc6c74fdba802c04175321520c92556c8a43fe79bf3f56d9fb80b82e1b7b60ff50c1bdea8fdcf94bb2e22fd
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,14 @@ All notable changes to the process_executer gem will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## v1.1.0 (2024-02-02)
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/main-branch/process_executer/compare/v1.0.2..v1.1.0)
|
11
|
+
|
12
|
+
Changes since v1.0.2:
|
13
|
+
|
14
|
+
* a473281 ProcessExecuter.spawn should indicate if the subprocess timed out or not (#43)
|
15
|
+
|
8
16
|
## v1.0.2 (2024-02-01)
|
9
17
|
|
10
18
|
[Full Changelog](https://github.com/main-branch/process_executer/compare/v1.0.1..v1.0.2)
|
data/README.md
CHANGED
@@ -77,7 +77,15 @@ important behaviorial differences:
|
|
77
77
|
2. A timeout can be specified using the `:timeout` option
|
78
78
|
|
79
79
|
If the command does not terminate before the timeout, the process is killed by
|
80
|
-
sending it the SIGKILL signal.
|
80
|
+
sending it the SIGKILL signal. The returned status object's `timeout?` attribute will
|
81
|
+
return `true`. For example:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
status = ProcessExecuter.spawn('sleep 10', timeout: 0.01)
|
85
|
+
status.signaled? #=> true
|
86
|
+
status.termsig #=> 9
|
87
|
+
status.timeout? #=> true
|
88
|
+
```
|
81
89
|
|
82
90
|
## Installation
|
83
91
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'delegate'
|
4
|
+
|
5
|
+
module ProcessExecuter
|
6
|
+
# A simple delegator for Process::Status that adds a `timeout?` attribute
|
7
|
+
#
|
8
|
+
# @api public
|
9
|
+
#
|
10
|
+
class Status < SimpleDelegator
|
11
|
+
extend Forwardable
|
12
|
+
|
13
|
+
# Create a new Status object from a Process::Status and timeout flag
|
14
|
+
#
|
15
|
+
# @param status [Process::Status] the status to delegate to
|
16
|
+
# @param timeout [Boolean] true if the process timed out
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# status = Process.wait2(pid).last
|
20
|
+
# timeout = false
|
21
|
+
# ProcessExecuter::Status.new(status, timeout)
|
22
|
+
#
|
23
|
+
# @api public
|
24
|
+
#
|
25
|
+
def initialize(status, timeout)
|
26
|
+
super(status)
|
27
|
+
@timeout = timeout
|
28
|
+
end
|
29
|
+
|
30
|
+
# @!attribute [r] timeout?
|
31
|
+
#
|
32
|
+
# True if the process timed out and was sent the SIGKILL signal
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# status = ProcessExecuter.spawn('sleep 10', timeout: 0.01)
|
36
|
+
# status.timeout? # => true
|
37
|
+
#
|
38
|
+
# @return [Boolean]
|
39
|
+
#
|
40
|
+
# @api public
|
41
|
+
#
|
42
|
+
def timeout? = @timeout
|
43
|
+
end
|
44
|
+
end
|
data/lib/process_executer.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'process_executer/monitored_pipe'
|
4
4
|
require 'process_executer/options'
|
5
|
+
require 'process_executer/status'
|
5
6
|
|
6
7
|
require 'timeout'
|
7
8
|
|
@@ -59,16 +60,16 @@ module ProcessExecuter
|
|
59
60
|
# @param pid [Integer] the process id
|
60
61
|
# @param options [ProcessExecuter::Options] the options used
|
61
62
|
#
|
62
|
-
# @return [
|
63
|
+
# @return [ProcessExecuter::Status] the status of the process
|
63
64
|
#
|
64
65
|
# @api private
|
65
66
|
#
|
66
67
|
private_class_method def self.wait_for_process(pid, options)
|
67
68
|
Timeout.timeout(options.timeout) do
|
68
|
-
Process.wait2(pid).last
|
69
|
+
ProcessExecuter::Status.new(Process.wait2(pid).last, false)
|
69
70
|
end
|
70
71
|
rescue Timeout::Error
|
71
72
|
Process.kill('KILL', pid)
|
72
|
-
Process.wait2(pid).last
|
73
|
+
ProcessExecuter::Status.new(Process.wait2(pid).last, true)
|
73
74
|
end
|
74
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: process_executer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Couball
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler-audit
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- lib/process_executer.rb
|
191
191
|
- lib/process_executer/monitored_pipe.rb
|
192
192
|
- lib/process_executer/options.rb
|
193
|
+
- lib/process_executer/status.rb
|
193
194
|
- lib/process_executer/version.rb
|
194
195
|
- process_executer.gemspec
|
195
196
|
homepage: https://github.com/main-branch/process_executer
|
@@ -199,8 +200,8 @@ metadata:
|
|
199
200
|
allowed_push_host: https://rubygems.org
|
200
201
|
homepage_uri: https://github.com/main-branch/process_executer
|
201
202
|
source_code_uri: https://github.com/main-branch/process_executer
|
202
|
-
changelog_uri: https://rubydoc.info/gems/process_executer/1.0
|
203
|
-
documentation_uri: https://rubydoc.info/gems/process_executer/1.0
|
203
|
+
changelog_uri: https://rubydoc.info/gems/process_executer/1.1.0/file/CHANGELOG.md
|
204
|
+
documentation_uri: https://rubydoc.info/gems/process_executer/1.1.0
|
204
205
|
rubygems_mfa_required: 'true'
|
205
206
|
post_install_message:
|
206
207
|
rdoc_options: []
|