@@ -27,6 +27,7 @@ import java.time.Duration
27
27
import java.time.OffsetDateTime
28
28
import java.time.temporal.ChronoUnit
29
29
import java.util.concurrent.Callable
30
+ import java.util.concurrent.Executors
30
31
import java.util.concurrent.TimeUnit
31
32
import java.util.function.Predicate
32
33
@@ -56,6 +57,7 @@ import nextflow.processor.Architecture
56
57
import nextflow.processor.TaskRun
57
58
import nextflow.script.bundle.ResourcesBundle
58
59
import nextflow.util.SysHelper
60
+ import nextflow.util.Threads
59
61
import org.slf4j.Logger
60
62
import org.slf4j.LoggerFactory
61
63
/**
@@ -127,12 +129,20 @@ class WaveClient {
127
129
// the cookie manager
128
130
cookieManager = new CookieManager ()
129
131
// create http client
130
- this . httpClient = HttpClient . newBuilder()
132
+ this . httpClient = newHttpClient()
133
+ }
134
+
135
+ protected HttpClient newHttpClient () {
136
+ final builder = HttpClient . newBuilder()
131
137
.version(HttpClient.Version . HTTP_1_1 )
132
138
.followRedirects(HttpClient.Redirect . NEVER )
133
139
.cookieHandler(cookieManager)
134
140
.connectTimeout(config. httpOpts(). connectTimeout())
135
- .build()
141
+ // use virtual threads executor if enabled
142
+ if ( Threads . useVirtual() )
143
+ builder. executor(Executors . newVirtualThreadPerTaskExecutor())
144
+ // build and return the new client
145
+ return builder. build()
136
146
}
137
147
138
148
WaveConfig config () { return config }
0 commit comments