cmds 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c155b3a2266b44990db163f49efec7a59044a3b
4
- data.tar.gz: f5fa951737f8b51a0a95aee8f49d3ec7344f3a06
3
+ metadata.gz: fb76b191ec12117d2d68bef750fe3f613d770cc5
4
+ data.tar.gz: 5afb4768e3fada0c9d088b2552ead175c46d7a94
5
5
  SHA512:
6
- metadata.gz: d879ac96441d732374252beea066e84f2a1fc771ee21cea94374266b02ea02fdb8b47d8fd4771e8aaaed77d6176fb750d8ace803584fe65ebd5469394d8575be
7
- data.tar.gz: cf7e0c8d02f586e8353b494baaf5a0d9171236708243d694ea50a80eadf96d8f4f975bd152345d834bcb39747eaae5e94fc5981d74944f8ff6f4cd5848a1e3f2
6
+ metadata.gz: ce525833832fd9d2086296e587233e91c4fa86f76bd4ff2ba2913b49d8816a3dd6261f4b768316782598d5e215ab76dbf794591701f927318dbddcf2b2f96b1f
7
+ data.tar.gz: 9c03d0736dd8c17559c86211bcbf4a4d384703362cd3b954370417d51da6e0c9a27b3ae3600fda6a07fae1814af24fd27d181b5e60fd78f2914847eb73eb844b
@@ -1,4 +1,9 @@
1
1
  class Cmds
2
+ # Class for handling IO from threads and passing it back via a {Queue} to
3
+ # the main thread for processing.
4
+ #
5
+ # NOTE These are one-use only! Don't try to reuse them.
6
+ #
2
7
  class IOHandler
3
8
  attr_accessor :in, :out, :err
4
9
 
@@ -6,6 +11,28 @@ class Cmds
6
11
  @in = nil
7
12
  @out = $stdout
8
13
  @err = $stderr
14
+
15
+ # Initialize a thread-safe queue for passing output from the IO threads
16
+ # back to the main thread
17
+ #
18
+ # NOTE This used to be done in {#start}, but I was seeing intermittent
19
+ # failures on Travis from what look like thread race conditions,
20
+ # guessing that it's from output arriving before {#start} is
21
+ # called, which totally looks like it could happen.
22
+ #
23
+ # See the failure in
24
+ #
25
+ # https://travis-ci.org/nrser/qb/jobs/348609316
26
+ #
27
+ # Really, I'm surprised I haven't hit more issues with this
28
+ # half-ass threading shit.
29
+ #
30
+ # Anyways, I moved the queue creation here, see if it helps.
31
+ #
32
+ @queue = Queue.new
33
+
34
+ # Flag that is set to `true` when {#start} is called.
35
+ @started = false
9
36
  end
10
37
 
11
38
  def out= value
@@ -22,7 +49,7 @@ class Cmds
22
49
  @out = block
23
50
  end
24
51
 
25
- # called in seperate thread handling process IO
52
+ # called in separate thread handling process IO
26
53
  def thread_send_out line
27
54
  @queue << [:out, line]
28
55
  end
@@ -31,19 +58,22 @@ class Cmds
31
58
  @err = block
32
59
  end
33
60
 
34
- # called in seperate thread handling process IO
61
+ # called in separate thread handling process IO
35
62
  def thread_send_err line
36
63
  @queue << [:err, line]
37
64
  end
38
-
65
+
66
+ # called in separate thread handling process IO
39
67
  def thread_send_line sym, line
40
68
  @queue << [sym, line]
41
69
  end
42
70
 
43
71
  def start
44
- # Initialize a thread-safe queue for passing output from the IO threads
45
- # back to the main thread
46
- @queue = Queue.new
72
+ if @started
73
+ raise "This handler has already been started / run"
74
+ end
75
+
76
+ @started = true
47
77
 
48
78
  # if out is a proc, it's not done
49
79
  out_done = ! @out.is_a?(Proc)
data/lib/cmds/version.rb CHANGED
@@ -16,6 +16,6 @@ class Cmds
16
16
  #
17
17
  # @return [String]
18
18
  #
19
- VERSION = '0.2.9'
19
+ VERSION = '0.2.10'
20
20
 
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-02 00:00:00.000000000 Z
11
+ date: 2018-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nrser