Skip to content

Conversation

@mjkkirschner
Copy link
Member

Purpose

cherry pick fixes from #14649 for CLIWrapper classes

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release 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

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;
Copy link
Contributor

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;

https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.wait?view=net-8.0#system-threading-tasks-task-wait(system-int32)

Copy link
Contributor

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.

Copy link
Member Author

@mjkkirschner mjkkirschner Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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.

@mjkkirschner
Copy link
Member Author

I am going to merge this.

  1. it fixes the deadlock on master
  2. The failing test is on master already - unclear how it did not fail earlier test runs.
  3. I will try to add a regression test for this deadlock in another PR.

@mjkkirschner mjkkirschner merged commit b9ebaca into DynamoDS:master Dec 1, 2023
@mjkkirschner mjkkirschner deleted the deadlockfix branch December 1, 2023 14:58
mjkkirschner added a commit to mjkkirschner/Dynamo that referenced this pull request Mar 19, 2024
* Tibi's changes

* review comments

* fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants