@@ -93,12 +93,12 @@ call the provided function `f()`, which must return a new connection instance of
9393This new connection instance will be tracked by the `Pod` and MUST be returned to the `Pod`
9494after use by calling `release(pod, conn)`.
9595"""
96- function acquire (f, pod:: Pod )
96+ function acquire (f, pod:: Pod , forcenew :: Bool = false )
9797 lock (pod. lock)
9898 try
9999 # if there are idle connections in the pod,
100100 # let's check if they're still valid and can be used again
101- while ! isempty (pod. conns)
101+ while ! forcenew && ! isempty (pod. conns)
102102 # Pod connections are FIFO, so grab the earliest returned connection
103103 # println("$(taskid()): checking idle_timeout connections for reuse")
104104 conn = popfirst! (pod. conns)
@@ -126,7 +126,7 @@ function acquire(f, pod::Pod)
126126 # is notified
127127 # println("$(taskid()): connection pool maxxed out; waiting for connection to be released to the pod")
128128 conn = wait (pod. lock)
129- if conn != = nothing
129+ if ! forcenew && conn != = nothing
130130 # println("$(taskid()): checking recently released connection validity for reuse")
131131 if isvalid (pod, conn)
132132 return trackconnection! (pod, conn)
@@ -242,11 +242,11 @@ created and passed the `max`, `idle_timeout`, and `reuse` keyword arguments if p
242242The provided function `f` must create a new connection instance of type `C`.
243243The acquired connection MUST be returned to the pool by calling `release(pool, key, conn)` exactly once.
244244"""
245- function acquire (f, pool:: Pool{C} , key; kw... ) where {C}
245+ function acquire (f, pool:: Pool{C} , key; forcenew :: Bool = false , kw... ) where {C}
246246 pod = lock (pool. lock) do
247247 get! (() -> Pod (C; kw... ), pool. pods, key)
248248 end
249- return acquire (f, pod)
249+ return acquire (f, pod, forcenew )
250250end
251251
252252function acquire (pool:: Pool{C} , key, conn:: C ; kw... ) where {C}
0 commit comments