-
Notifications
You must be signed in to change notification settings - Fork 30
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
Cannot async within traits #85
Comments
Hi @NuSkooler 👋 That's because WMI needs to be initialized per-thread, so any future that uses the connection cannot move between threads (aka, the resulting futures are
Let me know if this helps! |
@ohadravid Thanks, that makes sense. This does leave me in a dilemma, though it's likely my being fairly new to Rust: Removing Send trickles throughout the code meaning I can from my understanding, no longer use this method in other async/tokio code. Is there a work around?
The work around I'm using right now is hoisting the work to non-async code that's wrapped with Tokio |
Maybe something like #55 (comment) can help in your case? |
@ohadravid That looks great, I'll check it out. Thanks! |
I'm able to use
async_query()
in simple tests, but not within an async trait. A simple example:Results in the following:
Any ideas? Note that the same code works outside of a trait method.
The text was updated successfully, but these errors were encountered: