-
-
Notifications
You must be signed in to change notification settings - Fork 684
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
Add support for user-supplied executors #3091
Conversation
@stefnotch It looks like you have three PRs, #3989 #3990 and this one, that overlap and add mostly same code. Is that correct? This one adds user supplied executors, which seems to be unique. Would I want to merge this one and close the other two? |
@benwis Yes indeed. I first fixed the issue with an existing executor, and then used the slightly bigger API surface to support custom executors. So this PR builds on top of the code of #3089 . I figured I'd submit that as separate PRs, so that if this has a design issue, then it's at least easy to just merge #3089 . Regarding #3090 , feel free to just close it. It's significantly less important to have support for it if there's already an easy way for users to supply their own executor. (So yes, merging this and closing the other two would be perfect.) |
Looks like the CI is complaining about formatting. Can you run it through cargo fmt? |
Ah, I see, a nightly Rust toolchain was required to get the desired formatting output. Just as documented in the contributing.md file. Done :) |
The CI is still failing. :( And while I fully understand what went wrong, I have no idea how to fix it. What went wrong? I'm not sure how to go about changing the code to make it testable. |
Hello! I am pretty much interested by your PR since I need in #3063, a way to provide a Custom runtime for the I think you can solve the issue by adding a const https://doc.rust-lang.org/std/sync/struct.Once.html in your |
@raskyld That would work if I had one type of executor. With the custom executors part, I now have two separate executors that I have tests for
I also considered writing a custom executor for the unit tests that lets me swap out the underlying executor, but then the question arises: How do I test that? It's a bit of nontrivial code after all. |
I suppose another option would be to run the Edit: Nevermind, I read some more Rust documentation and figured out what the solution should be. |
Figured it out! I just had to use integration tests instead of unit tests. |
Question regarding the CI: Why does CI (any_spawner) run |
Yeah reading the code I now see the problem, we need the tests to run as two separated process. |
Just saw your comments, for some reason my GH page didn't get updated 🤣 Alright, swapping to integration tests make each module its own binary right? |
Yes, exactly. Rust by example confirms this
|
@stefnotch got another conflict for ya |
@benwis Fixed that for you :) |
This lets the user supply their own async executor. This should cover advanced use-cases, such as letting the user support the async_std crate.