You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have a process I want to monitor that is long running. It has small and infrequent output that I need to get in as soon as it is available. I'm running this process with swift-subprocess and monitoring its output by using SequenceOutput. In the custom execution closure, I only get the output either when the process exits or when the output size reaches readBufferSize defined in AsyncBufferSequence.
To Reproduce
Here is some sample code that demonstrates the problem:
let script = """
echo "[NOTICE] Important log line"
sleep 3600
"""
let catResult = try await Subprocess.run(
.path("/bin/bash"),
arguments: ["-c", script],
output: .sequence,
error: .discarded,
body: { (execution, _) in
for try await chunk in execution.standardOutput {
let string = chunk.withUnsafeBytes { String(decoding: $0, as: UTF8.self) }
if string.hasPrefix("[NOTICE]") {
// Do Something interesting
print(string)
}
}
return ""
}
)
Expected behavior
There should be a mechanism for getting the output as soon as it is available.
Environment (please complete the following information):
macOS 15
swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Additional context
I'll follow up with a PR that has the sketch for a proposed solution.
The text was updated successfully, but these errors were encountered:
when using SequenceOutput to emit standard output and standard error
as soon as it arrives.
Also, fixed a bug where DispatchIO.read could end up resuming a
Swift continuation multiple times
Resolvesswiftlang#39
Describe the bug
I have a process I want to monitor that is long running. It has small and infrequent output that I need to get in as soon as it is available. I'm running this process with swift-subprocess and monitoring its output by using
SequenceOutput
. In the custom execution closure, I only get the output either when the process exits or when the output size reachesreadBufferSize
defined inAsyncBufferSequence
.To Reproduce
Here is some sample code that demonstrates the problem:
Expected behavior
There should be a mechanism for getting the output as soon as it is available.
Environment (please complete the following information):
Additional context
I'll follow up with a PR that has the sketch for a proposed solution.
The text was updated successfully, but these errors were encountered: