From 9e1c4c1aa886dfc0c08c541978f977c0a0a660d6 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 2 Jun 2025 21:18:21 -0700 Subject: [PATCH] Schedule the next ti request after finishing the handling of request and updating program typing files This also fixes the flaky test --- internal/project/ata.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/project/ata.go b/internal/project/ata.go index a2daf41d0a..31dd9b1465 100644 --- a/internal/project/ata.go +++ b/internal/project/ata.go @@ -240,24 +240,6 @@ func (ti *TypingsInstaller) invokeRoutineToInstallTypings( packageNames []string, success bool, ) { - ti.pendingRunRequestsMu.Lock() - pendingRequestsCount := len(ti.pendingRunRequests) - var nextRequest *PendingRequest - if pendingRequestsCount == 0 { - ti.inFlightRequestCount-- - } else { - nextRequest = ti.pendingRunRequests[0] - if pendingRequestsCount == 1 { - ti.pendingRunRequests = nil - } else { - ti.pendingRunRequests = ti.pendingRunRequests[1:] - } - } - ti.pendingRunRequestsMu.Unlock() - if nextRequest != nil { - ti.invokeRoutineToInstallTypings(nextRequest) - } - if success { p.Logf("ATA:: Installed typings %v", packageNames) var installedTypingFiles []string @@ -330,6 +312,24 @@ func (ti *TypingsInstaller) invokeRoutineToInstallTypings( Status: core.IfElse(success, "Success", "Fail"), } } + + ti.pendingRunRequestsMu.Lock() + pendingRequestsCount := len(ti.pendingRunRequests) + var nextRequest *PendingRequest + if pendingRequestsCount == 0 { + ti.inFlightRequestCount-- + } else { + nextRequest = ti.pendingRunRequests[0] + if pendingRequestsCount == 1 { + ti.pendingRunRequests = nil + } else { + ti.pendingRunRequests = ti.pendingRunRequests[1:] + } + } + ti.pendingRunRequestsMu.Unlock() + if nextRequest != nil { + ti.invokeRoutineToInstallTypings(nextRequest) + } }, ) }