Skip to content

Commit 112659d

Browse files
committed
update coroutines management
1 parent e0a1d02 commit 112659d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ fun runGeneration(
290290
UtSettings.fuzzingTimeoutInMillis = (budgetForMethod * fuzzingRatio).toLong()
291291

292292
//start controller that will activate symbolic execution
293-
GlobalScope.launch {
293+
GlobalScope.launch(currentContext) {
294294
delay(budgetForSymbolicExecution)
295295

296296
if (methodJob.isActive) {
@@ -371,7 +371,7 @@ fun runGeneration(
371371
}
372372

373373

374-
val cancellator = GlobalScope.launch {
374+
val cancellator = GlobalScope.launch(currentContext) {
375375
delay(remainingBudget())
376376
if (engineJob.isActive) {
377377
logger.warn { "Cancelling job because timeout $generationTimeout ms elapsed (real cancellation can take time)" }

utbot-junit-contest/src/main/kotlin/org/utbot/monitoring/StatisticsMonitoring.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ package org.utbot.monitoring
33
import java.io.File
44
import java.util.concurrent.TimeUnit
55
import kotlin.system.exitProcess
6+
import kotlinx.coroutines.GlobalScope
7+
import kotlinx.coroutines.cancel
8+
import kotlinx.coroutines.cancelChildren
9+
import kotlinx.coroutines.job
610
import kotlinx.serialization.encodeToString
711
import kotlinx.serialization.json.Json
812
import mu.KotlinLogging
@@ -14,6 +18,7 @@ import org.utbot.contest.GlobalStats
1418
import org.utbot.contest.Paths
1519
import org.utbot.contest.Tool
1620
import org.utbot.contest.runEstimator
21+
import org.utbot.framework.plugin.api.util.utContext
1722
import org.utbot.framework.plugin.services.JdkInfoService
1823
import org.utbot.instrumentation.ConcreteExecutor
1924

@@ -71,6 +76,8 @@ fun main(args: Array<String>) {
7176

7277
}
7378

79+
utContext.cancelChildren()
80+
utContext.cancel()
7481
ConcreteExecutor.defaultPool.forceTerminateProcesses()
7582
System.gc()
7683
}

0 commit comments

Comments
 (0)