From ca4a4ece90ac71d6067a645ca8a2164d7be06323 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 21 Nov 2024 18:41:31 +0100 Subject: [PATCH] In `compile` command try to release the package manager lock ASAP (#2741) * In `compile` command try to release the package manager lock ASAP * Applied suggestion from code review --- commands/service_compile.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/commands/service_compile.go b/commands/service_compile.go index 37f401397de..a7ce1ea2bbf 100644 --- a/commands/service_compile.go +++ b/commands/service_compile.go @@ -22,6 +22,7 @@ import ( "io" "sort" "strings" + "sync" "time" "github.com/arduino/arduino-cli/commands/cmderrors" @@ -81,6 +82,7 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu if err != nil { return err } + release = sync.OnceFunc(release) defer release() if pme.Dirty() { @@ -358,6 +360,10 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu targetBoard.String(), "'build.board'", sketchBuilder.GetBuildProperties().Get("build.board")) + "\n")) } + // Release package manager + release() + + // Perform the actual build if err := sketchBuilder.Build(); err != nil { return &cmderrors.CompileFailedError{Message: err.Error()} }