-
Notifications
You must be signed in to change notification settings - Fork 634
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
cherry pick CLIWrapper deadlock fix #14662
Conversation
@@ -145,7 +145,7 @@ protected virtual async Task<string> GetData(int timeoutms) | |||
return writer.ToString(); | |||
} | |||
}); | |||
var completedTask = await Task.WhenAny(readStdOutTask, Task.Delay(TimeSpan.FromMilliseconds(timeoutms))); | |||
var completedTask = Task.WhenAny(readStdOutTask, Task.Delay(TimeSpan.FromMilliseconds(timeoutms))).Result; | |||
//if the completed task was our read std out task, then return the data | |||
//else we timed out, so return an empty string. | |||
return completedTask == readStdOutTask ? readStdOutTask.Result : string.Empty; |
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.
we might be able to simplify lines 148 to 151 by using
return readStdOutTask.Wait(timeoutms) ? readStdOutTask.Result : string.Empty;
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.
either way we go, please test that the timeout can be reached without issues.
Ex Add a Thread.Sleep(timeoutms *2) in the TaskRun delegate.
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.
@pinzart90 - does this test already cover what you are concerned about - or not?
https://github.com/DynamoDS/Dynamo/blob/master/test/Libraries/DynamoUtilitiesTests/CLIWrapperTests.cs#L47
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.
@pinzart90 I've added another test and slightly modified the GetData method to make it possible to inject a mock readLine delegate that will be invoked inside the Task delegate so we can sleep or return data etc.
I am going to merge this.
|
* Tibi's changes * review comments * fix test
Purpose
cherry pick fixes from #14649 for CLIWrapper classes
Declarations
Check these if you believe they are true
*.resx
filesRelease Notes
(FILL ME IN) Brief description of the fix / enhancement. Mandatory section
Reviewers
(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)
(FILL ME IN, optional) Any additional notes to reviewers or testers.
FYIs
(FILL ME IN, Optional) Names of anyone else you wish to be notified of