From 241d65aa3da077a0d926f890fd3137bc4f9ca8a3 Mon Sep 17 00:00:00 2001 From: Ekaterina Tochilina Date: Wed, 15 Nov 2023 23:18:14 +0300 Subject: [PATCH] new attempt --- .../usvm/runner/PythonSymbolicAnalysisRunner.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/usvm-python/usvm-python-runner/src/main/kotlin/org/usvm/runner/PythonSymbolicAnalysisRunner.kt b/usvm-python/usvm-python-runner/src/main/kotlin/org/usvm/runner/PythonSymbolicAnalysisRunner.kt index 49f1f01b92..d3576d9706 100644 --- a/usvm-python/usvm-python-runner/src/main/kotlin/org/usvm/runner/PythonSymbolicAnalysisRunner.kt +++ b/usvm-python/usvm-python-runner/src/main/kotlin/org/usvm/runner/PythonSymbolicAnalysisRunner.kt @@ -20,10 +20,14 @@ class PythonSymbolicAnalysisRunnerImpl( receiver: USVMPythonAnalysisResultReceiver, isCancelled: () -> Boolean ) { + val start = System.currentTimeMillis() val processBuilder = setupEnvironment(runConfig) val process = processBuilder.start() - val readingThread = ReadingThread(serverSocketChannel, receiver, isCancelled) - val waitingThread = WaitingThread(process, runConfig, readingThread, isCancelled) + val newIsCancelled = { + isCancelled() || System.currentTimeMillis() - start < runConfig.timeoutMs + } + val readingThread = ReadingThread(serverSocketChannel, receiver, newIsCancelled) + val waitingThread = WaitingThread(process, readingThread, newIsCancelled) try { readingThread.start() waitingThread.start() @@ -68,18 +72,15 @@ class PythonSymbolicAnalysisRunnerImpl( class WaitingThread( private val process: Process, - private val runConfig: USVMPythonRunConfig, private val readingThread: Thread, private val isCancelled: () -> Boolean ): Thread() { override fun run() { val start = System.currentTimeMillis() - while (System.currentTimeMillis() - start < runConfig.timeoutMs && readingThread.isAlive && process.isAlive && !isCancelled()) { + while (readingThread.isAlive && process.isAlive && !isCancelled()) { sleep(10) } - while (readingThread.isAlive) { - readingThread.interrupt() - } + readingThread.interrupt() } }