Skip to content

Commit fcdf071

Browse files
chore: remove stale thread local checks (#4)
1 parent d33a782 commit fcdf071

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

lib/openai/pooled_net_requester.rb

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,33 +85,16 @@ def build_request(request, &)
8585
# @param url [URI::Generic]
8686
# @param blk [Proc]
8787
#
88-
private def with_pool(url, &blk)
88+
private def with_pool(url, &)
8989
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-
10290
pool =
10391
@mutex.synchronize do
10492
@pools[origin] ||= ConnectionPool.new(size: @size) do
10593
self.class.connect(url)
10694
end
10795
end
10896

109-
pool.with do |conn|
110-
th[key] = true
111-
blk.call(conn)
112-
ensure
113-
th[key] = nil
114-
end
97+
pool.with(&)
11598
end
11699

117100
# @private

0 commit comments

Comments
 (0)