thready 0.0.2
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/.gitignore +18 -0
- data/Gemfile +6 -0
- data/LICENSE +22 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/app.rb +14 -0
- data/lib/thready/version.rb +3 -0
- data/lib/thready.rb +41 -0
- data/thready.gemspec +20 -0
- metadata +62 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Alex Chaffee
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Thready
|
2
|
+
|
3
|
+
Sets up a signal handler so when your app receives a SIGQUIT it dumps
|
4
|
+
information about the currently running threads. On Unix (including MacOS)
|
5
|
+
this usually happens when you press control-backslash.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'thready'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install thready
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Sometime during your program's initialization, do
|
24
|
+
|
25
|
+
require "thready"
|
26
|
+
|
27
|
+
Then while it's running, press
|
28
|
+
|
29
|
+
Ctrl-\\
|
30
|
+
|
31
|
+
This gem is only intended to be run during development and testing.
|
32
|
+
In fact, you probably shouldn't even check it in to your version control
|
33
|
+
system.
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
1. Fork it
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/app.rb
ADDED
data/lib/thready.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "thready/version"
|
2
|
+
|
3
|
+
Signal.trap('QUIT') do
|
4
|
+
puts
|
5
|
+
Thready.list_threads
|
6
|
+
end
|
7
|
+
|
8
|
+
puts "Thready installed. Press Ctrl-\\ to see the current threads."
|
9
|
+
|
10
|
+
module Thready
|
11
|
+
|
12
|
+
def self.list_threads
|
13
|
+
threads = Thread.list
|
14
|
+
puts "#{Time.now}\t#{threads.size} thread#{'s' if threads.size != 1}:"
|
15
|
+
threads.each do |t|
|
16
|
+
puts
|
17
|
+
|
18
|
+
data = [
|
19
|
+
"id: #{t.object_id}",
|
20
|
+
"status: #{t.status}",
|
21
|
+
#t.backtrace.first
|
22
|
+
]
|
23
|
+
puts data.join("\t")
|
24
|
+
|
25
|
+
puts "\t" + t.backtrace.join("\n\t") if t.backtrace
|
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
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/thready.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/thready/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Alex Chaffee"]
|
6
|
+
gem.email = ["alex@stinky.com"]
|
7
|
+
gem.description = %q{Dumps thread information to stdout when you press control-backslash.}
|
8
|
+
gem.summary = %q{Sets up a signal handler so when your app receives a SIGQUIT it dumps
|
9
|
+
information about the currently running threads. On Unix (including MacOS)
|
10
|
+
this usually happens when you press control-backslash.
|
11
|
+
}
|
12
|
+
gem.homepage = ""
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($\)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.name = "thready"
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.version = Thready::VERSION
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thready
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alex Chaffee
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-03 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Dumps thread information to stdout when you press control-backslash.
|
15
|
+
email:
|
16
|
+
- alex@stinky.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- app.rb
|
27
|
+
- lib/thready.rb
|
28
|
+
- lib/thready/version.rb
|
29
|
+
- thready.gemspec
|
30
|
+
homepage: ''
|
31
|
+
licenses: []
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
hash: -1993592577172457201
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
hash: -1993592577172457201
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.8.24
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: Sets up a signal handler so when your app receives a SIGQUIT it dumps information
|
60
|
+
about the currently running threads. On Unix (including MacOS) this usually happens
|
61
|
+
when you press control-backslash.
|
62
|
+
test_files: []
|