handle lock inside goroutine

Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
mudler
2025-03-25 18:48:15 +01:00
parent e26b55a6a8
commit ddc7d0e100

View File

@@ -196,28 +196,28 @@ func (t *Slack) handleChannelMessage(
currentConv := t.conversationTracker.GetConversation(t.channelID) currentConv := t.conversationTracker.GetConversation(t.channelID)
// Lock the conversation mutex to update the conversation history
t.processing.Lock()
// If we are already processing something, stop the current action
if t.processingMessage {
a.StopAction()
} else {
t.processingMessage = true
}
t.processing.Unlock()
// Defer to reset the processing flag
defer func() {
t.processing.Lock()
t.processingMessage = false
t.processing.Unlock()
}()
message := replaceUserIDsWithNamesInMessage(api, cleanUpUsernameFromMessage(ev.Text, b)) message := replaceUserIDsWithNamesInMessage(api, cleanUpUsernameFromMessage(ev.Text, b))
go func() { go func() {
// Lock the conversation mutex to update the conversation history
t.processing.Lock()
// If we are already processing something, stop the current action
if t.processingMessage {
a.StopAction()
} else {
t.processingMessage = true
}
t.processing.Unlock()
// Defer to reset the processing flag
defer func() {
t.processing.Lock()
t.processingMessage = false
t.processing.Unlock()
}()
imageBytes := new(bytes.Buffer) imageBytes := new(bytes.Buffer)
mimeType := "image/jpeg" mimeType := "image/jpeg"