smol-rs / async-compat

Compatibility adapter between tokio and futures
Apache License 2.0
156 stars 12 forks source link

Reuse existing tokio runtime if one exists #30

Closed bonsairobo closed 5 months ago

bonsairobo commented 8 months ago

Fixes #29

bonsairobo commented 8 months ago

@notgull I also tried adding this test:

    #[test]
    fn fallback_runtime_is_created_if_none_exists() {
        futures::executor::block_on(async { println!("foo") }.compat());

        assert!(TOKIO1.fallback_rt.is_some());
    }

But I realized unit testing this is kind of challenging since all tests are running in parallel, and creating a runtime in one test might affect the outcome of a different test.

I could make them integration tests to run them in separate processes, although I would need some public API to inspect whether the fallback runtime was created.

flisky commented 5 months ago

Anything I can help to push this forward? I have a perfect user case when using both uniffi and rustls-platform-verifier.

notgull commented 5 months ago

Sorry, this one fell through the cracks. I'll review it once I have time.