-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Multi-thread pulling of out put from AsyncProcess #8549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
We are seeing hangs on Windows when SwiftPM tests itself. Looking at how AsyncProcess pulls stdout and stderr, I can see that there may be conditions where the streams aren't fully drained causing the hang. The proper way to do this, like it's done on the other platforms is to create a thread for each stream.
A fatal error was happening in the PackageLoadingTests. Removed the caching of the manifest loader so that if it fails it can properly throw an exception.
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, I've lost count of how many times I've fixed this same problem with uses of Process
. Really looking forward to adopting swift-subprocess everywhere, which is async-native.
Looks like readabilityHandler is invoked on a private serial Dispatch queue owned by the FileHandle; I'm not sure this is a scenario where a hang could be caused, but it's hard to tell since the Swift Concurrency / GCD interaction is complex. This approach is worth trying though, since a pthread provides a pretty strong independence guarantee.
@swift-ci test windows |
@@ -17,7 +17,6 @@ import _InternalTestSupport | |||
import XCTest | |||
|
|||
class PackageDescriptionLoadingTests: XCTestCase, ManifestLoaderDelegate { | |||
lazy var manifestLoader = ManifestLoader(toolchain: try! UserToolchain.default, delegate: self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: can we instantiate manifestLoader
in a setUp(...)
call to ensure each test instantiates/creates its own object?
@@ -17,7 +17,6 @@ import _InternalTestSupport | |||
import XCTest | |||
|
|||
class PackageDescriptionLoadingTests: XCTestCase, ManifestLoaderDelegate { | |||
lazy var manifestLoader = ManifestLoader(toolchain: try! UserToolchain.default, delegate: self) | |||
var parsedManifest = ThreadSafeBox<AbsolutePath>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: can we instantiate parsedManifest
in a setUp(...)
call to ensure each test instantiates/creates its own object?
Still hanging, even removing the --parallel. Trying one more attempt at going pure win32. But, yes, subprocess would come in handy right now. |
To make sure it's clear what AsyncProcess is doing on Windows, Replace the use of Foundation's Process with direct calls to win32's CreateProcessW.
Consistently seeing the GitRepository tests hanging. Will try a couple of more times to confirm. |
@swift-ci please test self hosted windows |
Huh, that was it. I'm going to abandon this and go back to using Foundation.Process but with the multi-threaded reads. And then make sure multiple gits aren't running at the same time. |
We are seeing hangs on Windows when SwiftPM tests itself. Looking at how AsyncProcess pulls stdout and stderr, I can see that there may be conditions where the streams aren't fully drained causing the hang. The proper way to do this, like it's done on the other platforms is to create a thread for each stream.