From 06a50ea9164b4e366fc265eff25309c3f17283b3 Mon Sep 17 00:00:00 2001 From: nhatthm Date: Wed, 30 Jul 2025 14:59:41 +0200 Subject: [PATCH] Fix segmentation violation --- init_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/init_test.go b/init_test.go index a64fda3..7580e92 100644 --- a/init_test.go +++ b/init_test.go @@ -2,6 +2,7 @@ package python_test import ( "os" + "runtime" "testing" python3 "go.nhat.io/python/v3" @@ -9,7 +10,12 @@ import ( // TestMain is the entry point for the test suite. func TestMain(m *testing.M) { - defer python3.Finalize() + runtime.LockOSThread() - os.Exit(m.Run()) // nolint: gocritic + ret := m.Run() + + python3.Finalize() + runtime.UnlockOSThread() + + os.Exit(ret) }