Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113

Liang Ding89fd4d926464
diff --git a/kernel/model/conf.go b/kernel/model/conf.go
index 17497bd3e7..3648213379 100644
--- a/kernel/model/conf.go
+++ b/kernel/model/conf.go
@@ -406,12 +406,6 @@ func Close(force bool, execInstallPkg int) (exitCode int) {
}
}
- //util.UIProcessIDs.Range(func(key, _ interface{}) bool {
- // pid := key.(string)
- // util.Kill(pid)
- // return true
- //})
-
waitSecondForExecInstallPkg := false
if !skipNewVerInstallPkg() {
newVerInstallPkgPath := getNewVerInstallPkgPath()
diff --git a/kernel/task/queue.go b/kernel/task/queue.go
index c0d2850da1..93518326ba 100644
--- a/kernel/task/queue.go
+++ b/kernel/task/queue.go
@@ -111,6 +111,11 @@ const (
func Loop() {
for {
time.Sleep(10 * time.Millisecond)
+ if QueueStatusClosing == taskQueueStatus {
+ clearQueue()
+ break
+ }
+
task := popTask()
if nil == task {
continue
@@ -121,9 +126,6 @@ func Loop() {
}
func CloseWait() {
- queueLock.Lock()
- defer queueLock.Unlock()
-
taskQueueStatus = QueueStatusClosing
for {
time.Sleep(10 * time.Millisecond)
@@ -133,6 +135,13 @@ func CloseWait() {
}
}
+func clearQueue() {
+ queueLock.Lock()
+ defer queueLock.Unlock()
+
+ taskQueue = []*Task{}
+}
+
func popTask() (ret *Task) {
queueLock.Lock()
defer queueLock.Unlock()