Skip to content

Commit d1f7beb

Browse files
committed
use a custom thread factory to mark our async handler threads as daemons
1 parent fc830bf commit d1f7beb

File tree

1 file changed

+8
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime

1 file changed

+8
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/AsyncHandler.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.util.concurrent.ConcurrentLinkedQueue;
4545
import java.util.concurrent.Executors;
4646
import java.util.concurrent.ScheduledExecutorService;
47+
import java.util.concurrent.ThreadFactory;
4748
import java.util.concurrent.TimeUnit;
4849
import java.util.concurrent.locks.Lock;
4950
import java.util.concurrent.locks.ReentrantLock;
@@ -91,7 +92,13 @@ default int frameIndex() {
9192
}
9293
}
9394

94-
private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(2);
95+
private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(2, new ThreadFactory() {
96+
public Thread newThread(Runnable r) {
97+
Thread t = Executors.defaultThreadFactory().newThread(r);
98+
t.setDaemon(true);
99+
return t;
100+
}
101+
});
95102
private final ConcurrentLinkedQueue<AsyncAction> scheduledActions = new ConcurrentLinkedQueue<>();
96103
private boolean hasScheduledAction = false;
97104
private final Lock executingScheduledActions = new ReentrantLock();

0 commit comments

Comments
 (0)