connection_pool 2.5.4 → 2.5.5
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/Changes.md +6 -0
- data/lib/connection_pool/timed_stack.rb +14 -4
- data/lib/connection_pool/version.rb +1 -1
- data/lib/connection_pool.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 24c74a1caa5e04827c47155b75e19805bcda4c329e28793309dfa95b5881c4bd
|
|
4
|
+
data.tar.gz: 23aadf2da494be8c3314039700606cd4e01b58d6cae1f45e3b7cdef57a98e7bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f2385ddf4619ebc1bf9e2f202024b330c170ae2e4e7e63480be0f556242140af75eb3d272f6d262b2fc859625f0861c560af6a58c20bea3d69b005e2d248472
|
|
7
|
+
data.tar.gz: 0ac5103c69aa2e8226d2fa872714f9bd611b24ea171e91ce3d7a3c9be62b9887e24916cf4b6b1e5bc8c407349f87c3ea855c4659dbf5f3f137cd45738301d1a6
|
data/Changes.md
CHANGED
|
@@ -54,9 +54,12 @@ class ConnectionPool::TimedStack
|
|
|
54
54
|
# immediately returned. If no connection is available within the given
|
|
55
55
|
# timeout a ConnectionPool::TimeoutError is raised.
|
|
56
56
|
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
#
|
|
57
|
+
# @option options [Float] :timeout (0.5) Wait this many seconds for an available entry
|
|
58
|
+
# @option options [Class] :exception (ConnectionPool::TimeoutError) Exception class to raise
|
|
59
|
+
# if an entry was not available within the timeout period. Use `exception: false` to return nil.
|
|
60
|
+
#
|
|
61
|
+
# The +timeout+ argument will be removed in 3.0.
|
|
62
|
+
# Other options may be used by subclasses that extend TimedStack.
|
|
60
63
|
def pop(timeout = 0.5, options = {})
|
|
61
64
|
options, timeout = timeout, 0.5 if Hash === timeout
|
|
62
65
|
timeout = options.fetch :timeout, timeout
|
|
@@ -73,7 +76,14 @@ class ConnectionPool::TimedStack
|
|
|
73
76
|
return connection if connection
|
|
74
77
|
|
|
75
78
|
to_wait = deadline - current_time
|
|
76
|
-
|
|
79
|
+
if to_wait <= 0
|
|
80
|
+
exc = options.fetch(:exception, ConnectionPool::TimeoutError)
|
|
81
|
+
if exc
|
|
82
|
+
raise ConnectionPool::TimeoutError, "Waited #{timeout} sec, #{length}/#{@max} available"
|
|
83
|
+
else
|
|
84
|
+
return nil
|
|
85
|
+
end
|
|
86
|
+
end
|
|
77
87
|
@resource.wait(@mutex, to_wait)
|
|
78
88
|
end
|
|
79
89
|
end
|
data/lib/connection_pool.rb
CHANGED
|
@@ -104,6 +104,9 @@ class ConnectionPool
|
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
def with(options = {})
|
|
107
|
+
# We need to manage exception handling manually here in order
|
|
108
|
+
# to work correctly with `Timeout.timeout` and `Thread#raise`.
|
|
109
|
+
# Otherwise an interrupted Thread can leak connections.
|
|
107
110
|
Thread.handle_interrupt(Exception => :never) do
|
|
108
111
|
conn = checkout(options)
|
|
109
112
|
begin
|