Skip to content

Conversation

@davidomid
Copy link
Contributor

@davidomid davidomid commented Apr 19, 2019

Fix for issue #1020

Removed redundant multithreading which was implemented using Task.Run.

@dennisdoomen
Copy link
Member

It hang again.

@dennisdoomen
Copy link
Member

Maybe we try using what I've done in Chill: https://github.com/ChillBDD/Chill/pull/78/files

@davidomid
Copy link
Contributor Author

Maybe we try using what I've done in Chill: https://github.com/ChillBDD/Chill/pull/78/files

Thanks very much for this link. Interesting solution! I'll see what I can do :)

@davidomid
Copy link
Contributor Author

davidomid commented Apr 26, 2019

@dennisdoomen the build is now passing. Please review this pull request and let me know your thoughts.

Thanks very much again for that ChillBDD suggestion.

@jnyrup
Copy link
Member

jnyrup commented Apr 29, 2019

If I understand the purpose of NoSynchronizationContextScope, it is meant to be called at the boundaries and then avoiding having to call ConfigureAwait(false) everywhere deeper in the stack.

If that is correct, shouldn't it be enough to only call NoSynchronizationContextScope in:

  • public static ExecutionTime ExecutionTime(this Func<Task> action)
  • public static AsyncFunctionAssertions Should(this Func<Task> action)
  • public static AsyncFunctionAssertions Should<T>(this Func<Task<T>> action)

as they are, as far as I could see, exactly the boundaries of calling Task and Task<T>?

@davidomid
Copy link
Contributor Author

If I understand the purpose of NoSynchronizationContextScope, it is meant to be called at the boundaries and then avoiding having to call ConfigureAwait(false) everywhere deeper in the stack.

If that is correct, shouldn't it be enough to only call NoSynchronizationContextScope in:

  • public static ExecutionTime ExecutionTime(this Func<Task> action)
  • public static AsyncFunctionAssertions Should(this Func<Task> action)
  • public static AsyncFunctionAssertions Should<T>(this Func<Task<T>> action)

as they are, as far as I could see, exactly the boundaries of calling Task and Task<T>?

Thanks for the feedback, you've raised an excellent point. I'll get right on it :)

@davidomid
Copy link
Contributor Author

If I understand the purpose of NoSynchronizationContextScope, it is meant to be called at the boundaries and then avoiding having to call ConfigureAwait(false) everywhere deeper in the stack.

If that is correct, shouldn't it be enough to only call NoSynchronizationContextScope in:

  • public static ExecutionTime ExecutionTime(this Func<Task> action)
  • public static AsyncFunctionAssertions Should(this Func<Task> action)
  • public static AsyncFunctionAssertions Should<T>(this Func<Task<T>> action)

as they are, as far as I could see, exactly the boundaries of calling Task and Task<T>?

@jnyrup I've now pushed these changes. Please let me know if this is what you had in mind, or if you have other suggestions.

Thanks very much

@jnyrup
Copy link
Member

jnyrup commented Apr 30, 2019

Looks good!
(minor note: There are now a few superfluous namespaces and whitespace additions)

What happens if I execute one the following sync-over-async snippets, that calls into ActionAssertions and FunctionAssertions, respectively?

Action act = () => Task.Delay(0).Wait(0);
act.Should().NotThrow();
Func<bool> func = () => Task.Delay(0).Wait(0);
func.Should().NotThrow();

@davidomid
Copy link
Contributor Author

Looks good!
(minor note: There are now a few superfluous namespaces and whitespace additions)

My bad, I'll resolve this.

What happens if I execute one the following sync-over-async snippets, that calls into ActionAssertions and FunctionAssertions, respectively?

Action act = () => Task.Delay(0).Wait(0);
act.Should().NotThrow();
Func<bool> func = () => Task.Delay(0).Wait(0);
func.Should().NotThrow();

You've raised an excellent point. I could be mistaken but I don't think we have any test cases like this already. I'll create some and see if we have any potential issues.

Thanks very much!

@davidomid
Copy link
Contributor Author

@jnyrup I've made the changes to remove the superfluous namespaces and whitespace. I've also added some new tests with the scenarios you described above. Those tests seem to pass fine but it looks like the current build is failing due to one of those other flaky tests which are being investigated separately. Do we need to retry the AppVeyor build somehow?

Please let me know if you have any other issues or suggestions.

Thanks very much :)

Copy link
Member

@jnyrup jnyrup left a comment

Choose a reason for hiding this comment

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

Looks good @davidomid
Out of curiosity, does this solve any problem you've encountered, or did you look at the source code and found the use of await Task.Run() odd?

@dennisdoomen Do you know if we can manually trigger a build, just to verify that the failing test is "just" flaky and not permanently failing?

@davidomid
Copy link
Contributor Author

It just looked odd to me. When I looked into it, it looked a lot like it was only there to prevent deadlocks, so I thought it would be good to investigate and try to fix the underlying issue instead.

In terms of retrying the build, I could always push a blank commit to force it to rebuild but I don't want to pollute the commit history and would rather ask if there's an alternative first :)

@jnyrup
Copy link
Member

jnyrup commented Apr 30, 2019

@davidomid or, if you haven't tried before and would like to train your git-fu, you could trigger a build by rebasing on master into atomic commits, e.g.

  • Removed redundant multithreading
  • Added additional test cases for ActionAssertions and FunctionAssertions

Not the case for this PR, but for large PR atomic commits greatly simplifies reviewing.

@davidomid
Copy link
Contributor Author

@davidomid or, if you haven't tried before and would like to train your git-fu, you could trigger a build by rebasing on master into atomic commits, e.g.

  • Removed redundant multithreading
  • Added additional test cases for ActionAssertions and FunctionAssertions

Not the case for this PR, but for large PR atomic commits greatly simplifies reviewing.

I'll do it for this one :)

Thanks for the advice!

@davidomid davidomid force-pushed the Multithreading-removal branch from 6eb39b2 to c043c0f Compare April 30, 2019 22:14
@davidomid
Copy link
Contributor Author

@jnyrup @dennisdoomen

I've made the commits atomic and the latest build was successful :)

Please let me know if there's anything else you'd like me to resolve.

@dennisdoomen
Copy link
Member

Well done @davidomid. Thanks for the hard work.

@jnyrup jnyrup merged commit d1ec793 into fluentassertions:master May 1, 2019
jnyrup added a commit to jnyrup/fluentassertions that referenced this pull request Sep 27, 2023
These were introduced in fluentassertions#1027 when `AsyncFunctionAssertions` had blocking calls. We have since embraced async code better.
jnyrup added a commit that referenced this pull request Sep 28, 2023
These were introduced in #1027 when `AsyncFunctionAssertions` had blocking calls. We have since embraced async code better.
dennisdoomen pushed a commit that referenced this pull request Sep 29, 2023
These were introduced in #1027 when `AsyncFunctionAssertions` had blocking calls. We have since embraced async code better.
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.

3 participants