Skip to content
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

Only create tokio runtime once for block_on #55

Merged
merged 3 commits into from
Jan 16, 2020
Merged

Only create tokio runtime once for block_on #55

merged 3 commits into from
Jan 16, 2020

Conversation

udoprog
Copy link
Contributor

@udoprog udoprog commented Jan 15, 2020

Sets up a runtime in a lazy_static for blocking on current thread, and makes use of Builder::basic_scheduler to definitely avoid spinning up a thread pool for blocking the current thread.

Even if you don't want this particular PR, we should probably still make use of basic_scheduler.

@udoprog
Copy link
Contributor Author

udoprog commented Jan 15, 2020

I was curious if this would cause any issues, and it seems like it has. I'm guessing that the postgres internals require spawning to work on a different thread, but the basic_scheduler prevents this from making progress. I've switched to using the threaded_scheduler which should work as intended if that is the case.

Note that it's still worth being explicit about which scheduler to use, which would otherwise depend on the exact set of features used!

@mehcode mehcode merged commit 2562c35 into launchbadge:master Jan 16, 2020
@mehcode
Copy link
Member

mehcode commented Jan 16, 2020

Looks fine to me minus lazy_static as I'd rather avoid the macro. But I suppose it really doesn't matter all that much until rust-lang/rust#68198 is stable.


Regardless, thank you for noticing the TODO and fixing it. 💯

@udoprog udoprog deleted the tokio-runtime-once branch January 16, 2020 09:46
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.

2 participants