Skip to content

Commit

Permalink
Don't yield in tight loop when context process hasn't started (#5011)
Browse files Browse the repository at this point in the history
  • Loading branch information
rli authored Oct 28, 2024
1 parent a81caf6 commit 987e2ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "bugfix",
"description" : "Fix pointless busy loop in Amazon Q wasting CPU cycles (#5000)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import kotlinx.coroutines.yield
import software.aws.toolkits.core.utils.debug
import software.aws.toolkits.core.utils.error
import software.aws.toolkits.core.utils.getLogger
Expand All @@ -48,14 +47,15 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
return@launch
}

// TODO: need better solution for this
@Suppress("LoopWithTooManyJumpStatements")
while (true) {
if (encoderServer.isNodeProcessRunning()) {
// TODO: need better solution for this
delay(10000)
initAndIndex()
break
} else {
yield()
delay(10000)
}
}
}
Expand Down

0 comments on commit 987e2ae

Please sign in to comment.