Skip to content

Commit

Permalink
Increase generator command wait times
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleMayes committed Nov 2, 2023
1 parent 56330dd commit c120c15
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import kotlin.time.Duration.Companion.seconds

private val log = KotlinLogging.logger { /* */ }

private val waitTimeout = 30.seconds
private val killTimeout = 5.seconds

/** Executes the `bindgen` command and returns the output. */
fun bindgen(vararg args: String): String = execute("bindgen", arrayOf(*args))

Expand All @@ -38,7 +41,7 @@ private fun execute(command: String, args: Array<String>, input: String? = null,
fun operation(name: String, operation: () -> Unit) = Thread {
try {
Thread.currentThread().name = "$command-$name"
log.slow("`$command`: $name", 2.5.seconds) { operation() }
log.slow("`$command`: $name", waitTimeout / 2) { operation() }
} catch (e: Throwable) {
errors[name] = e
} finally {
Expand Down Expand Up @@ -69,17 +72,17 @@ private fun execute(command: String, args: Array<String>, input: String? = null,
)

threads.forEach { it.start() }
val countdown = latch.await(5, TimeUnit.SECONDS)
val countdown = latch.await(waitTimeout.inWholeMilliseconds, TimeUnit.MILLISECONDS)

val stdoutValue = stdout.get()
val stderrValue = stderr.get()
val errorsValue = errors.toMap()

if (process.isAlive) {
log.slow("`$command`: kill", 0.5.seconds) {
log.slow("`$command`: kill", killTimeout / 2) {
try {
process.destroy()
process.waitFor(1, TimeUnit.SECONDS)
process.waitFor(killTimeout.inWholeMilliseconds, TimeUnit.MILLISECONDS)
process.destroyForcibly()
} catch (e: Error) {
e.printStackTrace()
Expand Down

0 comments on commit c120c15

Please sign in to comment.