workhorse 0.6.3 → 0.6.4

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
  SHA256:
3
- metadata.gz: 42369906b8cebe1da36b01035d7a28e9a10af2b39186045d89866eafa9a9e1f8
4
- data.tar.gz: aa3f269bc9ec2b4b8e87403466ccf528cc5f2cc5fc60155c2e772e5fa562231e
3
+ metadata.gz: 3e0ec8f7b72f3bdfbe540ba647baf9ed2c746119e6592be2b95e8e3e1397e53c
4
+ data.tar.gz: 542e7ca25aca517b4539162cde18c211165b29ba8653b62653d6e0b6ecd1a715
5
5
  SHA512:
6
- metadata.gz: 790a0ee9aee36fa6b636e8bb9b252428b6d236ed6e45df3e3a3119de5cf25a40027fffe5e92f2968999311a9e14fafa35bc2e7c155df67faa54a334204af8a47
7
- data.tar.gz: 6642ffd446bb0666af1cbb96730ac8b13c276d1d9f0bf9db35ca3f0f8f86f3df868ab05cc6aefbe754e18f4f6b909e44b0dfee4d77e994c0f29f2b7ee2d2d08a
6
+ metadata.gz: c13715991ee9eb3195afd4cef7fc3c7789025bf445bb56750f90f3c2f885401ee40efd7125335e836453dcda63cb46a4a8c5488f6b24f96e3b5e57856b3f6071
7
+ data.tar.gz: 2d3f9d52eac7f1bbc9fd98ae2ba3ca57c8088b00ee5a0abe8865aeb2522dff0184f03360c9a17f375fee39a8d620d6ea2c95c861af35d686044a1f8e25dff01a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Workhorse Changelog
2
2
 
3
+ ## 0.6.4 - 2019-10-12
4
+
5
+ * Fix #22 where an exception with message `No live threads left. Deadlock?`
6
+ could be thrown in the worker processes.
7
+
3
8
  ## 0.6.3 - 2019-09-02
4
9
 
5
10
  * Fix examples in changelog, readme and generator for starting workers. Some of
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.3
1
+ 0.6.4
@@ -48,8 +48,17 @@ module Workhorse
48
48
  @size - @active_threads.value
49
49
  end
50
50
 
51
+ # Waits until the pool is shut down. This will wait forever unless you
52
+ # eventually call shutdown (either before calling `wait` or after it in
53
+ # another thread).
51
54
  def wait
52
- @executor.wait_for_termination
55
+ # Here we use a loop-sleep combination instead of using
56
+ # ThreadPoolExecutor's `wait_for_termination`. See issue #21 for more
57
+ # information.
58
+ loop do
59
+ break if @executor.shutdown?
60
+ sleep 0.1
61
+ end
53
62
  end
54
63
 
55
64
  # Shuts down the pool and waits for termination.
@@ -19,6 +19,40 @@ class Workhorse::PoolTest < WorkhorseTest
19
19
  end
20
20
  end
21
21
 
22
+ # This tries to reproduce issue #21 where the exception "No live threads left.
23
+ # Deadlock?" was raised when trying to call `wait` on a pool on which
24
+ # `shutdown` has not been called yet.
25
+ def test_issue_22
26
+ # ---------------------------------------------------------------
27
+ # Here we forcefully disconnect AR and force all other threads
28
+ # beside the current to exit, as issue #22 cannot be reproduced
29
+ # when there are other threads besides the current one around.
30
+ # ---------------------------------------------------------------
31
+ ActiveRecord::Base.connection_pool.disconnect
32
+
33
+ Thread.list.each do |thread|
34
+ thread.exit unless thread == Thread.current
35
+ end
36
+
37
+ # ---------------------------------------------------------------
38
+ # The following resulted in an exception and should now work
39
+ # without any exception.
40
+ # ---------------------------------------------------------------
41
+ assert_nothing_raised do
42
+ p = Workhorse::Pool.new(1)
43
+ p.post do
44
+ sleep 1
45
+ end
46
+
47
+ Thread.new do
48
+ sleep 2
49
+ p.shutdown
50
+ end
51
+
52
+ p.wait
53
+ end
54
+ end
55
+
22
56
  def test_on_idle
23
57
  on_idle_calls = Concurrent::AtomicFixnum.new
24
58
 
data/workhorse.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: workhorse 0.6.3 ruby lib
2
+ # stub: workhorse 0.6.4 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "workhorse".freeze
6
- s.version = "0.6.3"
6
+ s.version = "0.6.4"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Sitrox".freeze]
11
- s.date = "2019-09-02"
11
+ s.date = "2019-09-12"
12
12
  s.files = [".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, ".travis.yml".freeze, "CHANGELOG.md".freeze, "FAQ.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/rubocop".freeze, "lib/active_job/queue_adapters/workhorse_adapter.rb".freeze, "lib/generators/workhorse/install_generator.rb".freeze, "lib/generators/workhorse/templates/bin/workhorse.rb".freeze, "lib/generators/workhorse/templates/config/initializers/workhorse.rb".freeze, "lib/generators/workhorse/templates/create_table_jobs.rb".freeze, "lib/workhorse.rb".freeze, "lib/workhorse/daemon.rb".freeze, "lib/workhorse/daemon/shell_handler.rb".freeze, "lib/workhorse/db_job.rb".freeze, "lib/workhorse/enqueuer.rb".freeze, "lib/workhorse/jobs/cleanup_succeeded_jobs.rb".freeze, "lib/workhorse/jobs/run_active_job.rb".freeze, "lib/workhorse/jobs/run_rails_op.rb".freeze, "lib/workhorse/performer.rb".freeze, "lib/workhorse/poller.rb".freeze, "lib/workhorse/pool.rb".freeze, "lib/workhorse/scoped_env.rb".freeze, "lib/workhorse/worker.rb".freeze, "test/active_job/queue_adapters/workhorse_adapter_test.rb".freeze, "test/lib/db_schema.rb".freeze, "test/lib/jobs.rb".freeze, "test/lib/test_helper.rb".freeze, "test/workhorse/db_job_test.rb".freeze, "test/workhorse/enqueuer_test.rb".freeze, "test/workhorse/performer_test.rb".freeze, "test/workhorse/poller_test.rb".freeze, "test/workhorse/pool_test.rb".freeze, "test/workhorse/worker_test.rb".freeze, "workhorse.gemspec".freeze]
13
13
  s.rubygems_version = "3.0.3".freeze
14
14
  s.summary = "Multi-threaded job backend with database queuing for ruby.".freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workhorse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sitrox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-02 00:00:00.000000000 Z
11
+ date: 2019-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler