Random bug while running a command during process execution

Hi guys, I am trying actually to fix this part of my code. Basically, when my program run this part, it happen sometimes randomly the playCalculationAnimation is not runned. Any idea ?

def buildTasksFile
            processResult = IO::Memory.new

            requestedCommands = "CRYSTAL_WORKERS=#{Ism.settings.systemMakeOptions[2..-1]} crystal build #{ISM::Default::Filename::Task}.cr -o #{@settings.rootPath}#{ISM::Default::Filename::Task} -f json"

            Process.run(command: requestedCommands,
                        error: processResult,
                        shell: true,
                        chdir: "#{@settings.rootPath}") do |process|
                loop do
                    Fiber.yield
                    playCalculationAnimation(ISM::Default::CommandLine::CompilationWaitingText)
                    break if process.terminated?
                end
            end

            processResult.rewind

            if processResult.to_s != ""
                taskError = Array(ISM::TaskBuildingProcessError).from_json(processResult.to_s.gsub("\"size\":null","\"size\":0"))[-1]

                showTaskCompilationFailedMessage
                showTaskBuildingProcessErrorMessage(taskError, "#{@settings.rootPath}#{ISM::Default::Filename::Task}.cr")
                exitProgram
            end

            rescue error
                printSystemCallErrorNotification(error)
                exitProgram
        end

It’s possible your Fiber.yield switches execution to another fiber that ends up calling exit or something along those lines. In which case execution never has a chance to switch back to the other fiber to run playCalculationAnimation.

1 Like

So any solution in this case ?