Posts

Post marked as solved
3 Replies
0 Views
I came across this question because I was running instances of Process and connecting Pipe to the FileHandle and found it was using an excessive amount of CPU due to many calls to the handleInput function. The readabilityHandler property is set to this function to handle the data. What I found is that I needed to call waitForDataInBackgroundAndNotify which prevented the handler functions from being called frequently with no data. With your process make sure you call launch and waitUntilExit so that your function does not finish early. And if you are running a Command Line Tool you may want to add a call to dispatchMain() to prevent the process from terminating until the code calls exit. let outPipe = Pipe() let errPipe = Pipe() task.standardOutput = outPipe task.standardError = errPipe outPipe.fileHandleForReading.readabilityHandler = handleInput(fileHandle:) errPipe.fileHandleForReading.readabilityHandler = handleError(fileHandle:) outPipe.fileHandleForReading.waitForDataInBackgroundAndNotify() errPipe.fileHandleForReading.waitForDataInBackgroundAndNotify()
Post marked as solved
1 Replies
0 Views
I got the answer from a co-worker. It was a setting which I did not change myself but I was able to change it back. Under the menu: Debug > Debug Workflow check Always Show Disassembly to make sure it is not checked. This fixes the problem.