Skip to content

Commit 6c180b7

Browse files
committed
0.9.3, mark HTTP thread pool threads as daemons
1 parent 07fb0e5 commit 6c180b7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

requests/src/requests/Requester.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ trait BaseSession extends AutoCloseable {
4444
def send(method: String) = Requester(method, this)
4545

4646
// Executor and HttpClient for this session, lazily initialized
47-
lazy val executor: ExecutorService = Executors.newCachedThreadPool()
47+
lazy val executor: ExecutorService = Executors.newCachedThreadPool(new ThreadFactory {
48+
override def newThread(r: Runnable): Thread = {
49+
val t = new Thread(r, "requests-scala-http")
50+
t.setDaemon(true) // Mark as daemon threads to avoid blocking JVM shutdown
51+
t
52+
}
53+
})
4854
lazy val sharedHttpClient: HttpClient = BaseSession.buildHttpClient(
4955
proxy, cert, sslContext, verifySslCerts, connectTimeout, executor
5056
)

0 commit comments

Comments
 (0)