File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed
utbot-junit-contest/src/main/kotlin/org/utbot Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ enum class Tool {
139139 classFqn : String
140140 ) {
141141 val classStats: StatsForClass = try {
142- withUtContext(UtContext (project.classloader)) {
142+ withUtContext(ContextManager .createNewContext (project.classloader)) {
143143 runGeneration(
144144 project.name,
145145 cut,
Original file line number Diff line number Diff line change 1+ package org.utbot.contest
2+
3+ import kotlinx.coroutines.cancel
4+ import kotlinx.coroutines.cancelChildren
5+ import org.utbot.framework.plugin.api.util.UtContext
6+
7+ object ContextManager {
8+ private val currentContexts = mutableListOf<UtContext >()
9+
10+ fun createNewContext (classLoader : ClassLoader ) =
11+ UtContext (classLoader).apply {
12+ currentContexts.add(this )
13+ }
14+
15+ fun cancelAll () {
16+ currentContexts.forEach {
17+ it.cancelChildren()
18+ it.cancel()
19+ }
20+ currentContexts.clear()
21+ }
22+
23+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import org.utbot.common.ThreadBasedExecutor
1414import org.utbot.common.bracket
1515import org.utbot.common.info
1616import org.utbot.contest.ContestEstimatorJdkInfoProvider
17+ import org.utbot.contest.ContextManager
1718import org.utbot.contest.GlobalStats
1819import org.utbot.contest.Paths
1920import org.utbot.contest.Tool
@@ -76,8 +77,7 @@ fun main(args: Array<String>) {
7677
7778 }
7879
79- utContext.cancelChildren()
80- utContext.cancel()
80+ ContextManager .cancelAll()
8181 ConcreteExecutor .defaultPool.forceTerminateProcesses()
8282 System .gc()
8383 }
You can’t perform that action at this time.
0 commit comments