1
0
Fork 0

Remove OS thread locking for Go-Python calls

This appears to be no longer necessary, as Python handlers themselves
run in a separate thread pool.
This commit is contained in:
Alex Palaistras 2024-04-16 19:47:55 +01:00
parent 72ebb936d2
commit 0564557b83
2 changed files with 2 additions and 16 deletions

View File

@ -3,9 +3,7 @@ package whatsapp
import (
// Standard library.
"fmt"
"net/http"
"os"
"runtime"
// Third-party libraries.
_ "github.com/mattn/go-sqlite3"
@ -78,9 +76,8 @@ type Gateway struct {
TempDir string // The directory to create temporary files under.
// Internal variables.
container *sqlstore.Container
httpClient *http.Client
logger walog.Logger
container *sqlstore.Container
logger walog.Logger
}
// NewGateway returns a new, un-initialized Gateway. This function should always be followed by calls
@ -92,11 +89,6 @@ func NewGateway() *Gateway {
// SetLogHandler specifies the log handling function to use for all [Gateway] and [Session] operations.
func (w *Gateway) SetLogHandler(h HandleLogFunc) {
w.logger = HandleLogFunc(func(level ErrorLevel, message string) {
// Don't allow other Goroutines from using this thread, as this might lead to concurrent
// use of the GIL, which can lead to crashes.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
h(level, message)
})
}

View File

@ -7,7 +7,6 @@ import (
"fmt"
"math/rand"
"os"
"runtime"
"time"
// Third-party libraries.
@ -663,11 +662,6 @@ func (s *Session) propagateEvent(kind EventKind, payload *EventPayload) {
payload = &EventPayload{}
}
// Don't allow other Goroutines from using this thread, as this might lead to concurrent use of
// the GIL, which can lead to crashes.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
s.eventHandler(kind, payload)
}