thready 0.0.2 → 0.0.3

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.
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Thready
2
2
 
3
+ <http://github.com/alexch/thready>
4
+
5
+ by Alex Chaffee <http://alexchaffee.com>
6
+
3
7
  Sets up a signal handler so when your app receives a SIGQUIT it dumps
4
8
  information about the currently running threads. On Unix (including MacOS)
5
9
  this usually happens when you press control-backslash.
@@ -26,7 +30,7 @@ Sometime during your program's initialization, do
26
30
 
27
31
  Then while it's running, press
28
32
 
29
- Ctrl-\\
33
+ Ctrl-\
30
34
 
31
35
  This gem is only intended to be run during development and testing.
32
36
  In fact, you probably shouldn't even check it in to your version control
@@ -39,3 +43,11 @@ system.
39
43
  3. Commit your changes (`git commit -am 'Added some feature'`)
40
44
  4. Push to the branch (`git push origin my-new-feature`)
41
45
  5. Create new Pull Request
46
+
47
+ ## References
48
+
49
+ * http://en.wikipedia.org/wiki/Signal_(computing)
50
+ * http://en.wikipedia.org/wiki/SIGQUIT
51
+ * http://weblog.jamisbuck.org/2006/9/22/inspecting-a-live-ruby-process
52
+ * http://axonflux.com/inspect-a-live-running-ruby-process
53
+
data/app.rb CHANGED
@@ -6,9 +6,15 @@ $: << "#{here}/lib"
6
6
  require "thready"
7
7
 
8
8
  Thread.new {
9
+ @bar = 22
10
+ x = 10
9
11
  sleep 100
10
12
  }.run
11
13
 
12
- Thready.list_threads
13
- sleep 100
14
+ Thread.new {
15
+ y = 20
16
+ sleep 100
17
+ }
14
18
 
19
+
20
+ sleep 100
@@ -13,7 +13,7 @@ module Thready
13
13
  threads = Thread.list
14
14
  puts "#{Time.now}\t#{threads.size} thread#{'s' if threads.size != 1}:"
15
15
  threads.each do |t|
16
- puts
16
+ $stderr.puts
17
17
 
18
18
  data = [
19
19
  "id: #{t.object_id}",
@@ -24,15 +24,25 @@ module Thready
24
24
 
25
25
  puts "\t" + t.backtrace.join("\n\t") if t.backtrace
26
26
 
27
- if t.alive? and false
28
- t.set_trace_func proc { |event, file, line, id, binding, classname|
29
- t.set_trace_func(nil)
30
- printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
31
- binding.eval("instance_variables").each do |var|
32
- value = binding.eval("instance_variable_get(:#{var})")
33
- puts "\t@#{var} is #{value.inspect}"
34
- end
35
- }
27
+ if t.alive?
28
+ t.set_trace_func(proc do |event, file, line, id, binding, classname|
29
+ #if event == "line"
30
+ printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
31
+
32
+ p binding.eval("local_variables")
33
+ binding.eval("local_variables").each do |var|
34
+ value = binding.eval(var.to_s)
35
+ puts "\t#{var} is #{value.inspect}"
36
+ end
37
+
38
+ p binding.eval("instance_variables")
39
+ binding.eval("instance_variables").each do |var|
40
+ value = binding.eval("instance_variable_get(:@#{var})")
41
+ puts "\t@#{var} is #{value.inspect}"
42
+ end
43
+ t.set_trace_func(nil)
44
+ #end
45
+ end)
36
46
  end
37
47
 
38
48
  end
@@ -1,3 +1,3 @@
1
1
  module Thready
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
9
9
  information about the currently running threads. On Unix (including MacOS)
10
10
  this usually happens when you press control-backslash.
11
11
  }
12
- gem.homepage = ""
12
+ gem.homepage = "https://github.com/alexch/thready"
13
13
 
14
14
  gem.files = `git ls-files`.split($\)
15
15
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.name = "thready"
18
18
  gem.require_paths = ["lib"]
19
19
  gem.version = Thready::VERSION
20
+ gem.license = "MIT"
20
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thready
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-03 00:00:00.000000000 Z
12
+ date: 2012-07-06 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Dumps thread information to stdout when you press control-backslash.
15
15
  email:
@@ -27,8 +27,9 @@ files:
27
27
  - lib/thready.rb
28
28
  - lib/thready/version.rb
29
29
  - thready.gemspec
30
- homepage: ''
31
- licenses: []
30
+ homepage: https://github.com/alexch/thready
31
+ licenses:
32
+ - MIT
32
33
  post_install_message:
33
34
  rdoc_options: []
34
35
  require_paths:
@@ -39,18 +40,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
39
40
  - - ! '>='
40
41
  - !ruby/object:Gem::Version
41
42
  version: '0'
42
- segments:
43
- - 0
44
- hash: -1993592577172457201
45
43
  required_rubygems_version: !ruby/object:Gem::Requirement
46
44
  none: false
47
45
  requirements:
48
46
  - - ! '>='
49
47
  - !ruby/object:Gem::Version
50
48
  version: '0'
51
- segments:
52
- - 0
53
- hash: -1993592577172457201
54
49
  requirements: []
55
50
  rubyforge_project:
56
51
  rubygems_version: 1.8.24