File tree Expand file tree Collapse file tree 1 file changed +2
-19
lines changed Expand file tree Collapse file tree 1 file changed +2
-19
lines changed Original file line number Diff line number Diff line change @@ -85,33 +85,16 @@ def build_request(request, &)
85
85
# @param url [URI::Generic]
86
86
# @param blk [Proc]
87
87
#
88
- private def with_pool ( url , &blk )
88
+ private def with_pool ( url , &)
89
89
origin = OpenAI ::Util . uri_origin ( url )
90
- th = Thread . current
91
- key = :"#{ object_id } -#{ self . class . name } -connection_in_use_for_#{ origin } "
92
-
93
- if th [ key ]
94
- tap do
95
- conn = self . class . connect ( url )
96
- return blk . call ( conn )
97
- ensure
98
- conn . finish if conn &.started?
99
- end
100
- end
101
-
102
90
pool =
103
91
@mutex . synchronize do
104
92
@pools [ origin ] ||= ConnectionPool . new ( size : @size ) do
105
93
self . class . connect ( url )
106
94
end
107
95
end
108
96
109
- pool . with do |conn |
110
- th [ key ] = true
111
- blk . call ( conn )
112
- ensure
113
- th [ key ] = nil
114
- end
97
+ pool . with ( &)
115
98
end
116
99
117
100
# @private
You can’t perform that action at this time.
0 commit comments