| 1 | #[cfg(not(target_os = "windows"))] |
| 2 | fn mainrust-analyzer cargo pyo3-async-runtimes 0.28.0 main().() -> pyo3rust-analyzer cargo pyo3 0.28.0 crate/::PyResultrust-analyzer cargo pyo3 0.28.0 err/PyResult#<()> { |
| 3 | use pyo3rust-analyzer cargo pyo3 0.28.0 crate/::{preluderust-analyzer cargo pyo3 0.28.0 prelude/::*, typesrust-analyzer cargo pyo3 0.28.0 types/::PyTyperust-analyzer cargo pyo3 0.28.0 types/typeobject/PyType#}; |
| 4 | |
| 5 | Pythonrust-analyzer cargo pyo3 0.28.0 marker/Python#::initializerust-analyzer cargo pyo3 0.28.0 marker/impl#[`Python<'_>`]initialize().(); |
| 6 | |
| 7 | let mut builder = tokiorust-analyzer cargo tokio 1.49.0 crate/::runtimerust-analyzer cargo tokio 1.49.0 runtime/::Builderrust-analyzer cargo tokio 1.49.0 runtime/builder/Builder#::new_current_threadrust-analyzer cargo tokio 1.49.0 runtime/builder/impl#[Builder]new_current_thread().(); |
| 8 | builder.enable_allrust-analyzer cargo tokio 1.49.0 runtime/builder/impl#[Builder]enable_all().(); |
| 9 | |
| 10 | pyo3_async_runtimesrust-analyzer cargo pyo3-async-runtimes 0.28.0 crate/::tokiorust-analyzer cargo pyo3-async-runtimes 0.28.0 tokio/::initrust-analyzer cargo pyo3-async-runtimes 0.28.0 tokio/init().(builder); |
| 11 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::spawnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/spawn().(move || { |
| 12 | pyo3_async_runtimesrust-analyzer cargo pyo3-async-runtimes 0.28.0 crate/::tokiorust-analyzer cargo pyo3-async-runtimes 0.28.0 tokio/::get_runtimerust-analyzer cargo pyo3-async-runtimes 0.28.0 tokio/get_runtime().().block_onrust-analyzer cargo tokio 1.49.0 runtime/runtime/impl#[Runtime]block_on().(futures_utilrust-analyzer cargo futures-util 0.3.31 crate/::futurerust-analyzer cargo futures-util 0.3.31 future/::pendingrust-analyzer cargo futures-util 0.3.31 future/pending/pending().::<()>()); |
| 13 | }); |
| 14 | |
| 15 | Pythonrust-analyzer cargo pyo3 0.28.0 marker/Python#::attachrust-analyzer cargo pyo3 0.28.0 marker/impl#[`Python<'_>`]attach().(|py| { |
| 16 | // uvloop not supported on the free-threaded build yet |
| 17 | // https://github.com/MagicStack/uvloop/issues/642 |
| 18 | let sysconfig = py.importrust-analyzer cargo pyo3 0.28.0 marker/impl#[`Python<'py>`]import().("sysconfig")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 19 | let is_freethreaded = sysconfig.call_method1rust-analyzer cargo pyo3 0.28.0 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]call_method1().("get_config_var", ("Py_GIL_DISABLED",))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 20 | if is_freethreaded.is_truthyrust-analyzer cargo pyo3 0.28.0 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]is_truthy().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 21 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 22 | } |
| 23 | |
| 24 | // uvloop not yet supported on 3.14 |
| 25 | if py.version_inforust-analyzer cargo pyo3 0.28.0 marker/impl#[`Python<'py>`]version_info().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().(3, 14) { |
| 26 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 27 | } |
| 28 | |
| 29 | let uvloop = py.importrust-analyzer cargo pyo3 0.28.0 marker/impl#[`Python<'py>`]import().("uvloop")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 30 | uvloop.call_method0rust-analyzer cargo pyo3 0.28.0 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]call_method0().("install")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 31 | |
| 32 | // store a reference for the assertion |
| 33 | let uvloop: Pyrust-analyzer cargo pyo3 0.28.0 instance/Py#<PyAnyrust-analyzer cargo pyo3 0.28.0 types/any/PyAny#> = uvloop.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 34 | |
| 35 | pyo3_async_runtimesrust-analyzer cargo pyo3-async-runtimes 0.28.0 crate/::tokiorust-analyzer cargo pyo3-async-runtimes 0.28.0 tokio/::runrust-analyzer cargo pyo3-async-runtimes 0.28.0 tokio/run().(py, async move { |
| 36 | // verify that we are on a uvloop.Loop |
| 37 | Pythonrust-analyzer cargo pyo3 0.28.0 marker/Python#::attachrust-analyzer cargo pyo3 0.28.0 marker/impl#[`Python<'_>`]attach().(|py| -> PyResultrust-analyzer cargo pyo3 0.28.0 err/PyResult#<()> { |
| 38 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pyo3_async_runtimesrust-analyzer cargo pyo3-async-runtimes 0.28.0 crate/::tokiorust-analyzer cargo pyo3-async-runtimes 0.28.0 tokio/::get_current_looprust-analyzer cargo pyo3-async-runtimes 0.28.0 tokio/get_current_loop().(py)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 39 | .is_instancerust-analyzer cargo pyo3 0.28.0 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]is_instance().(uvloop.bindrust-analyzer cargo pyo3 0.28.0 instance/impl#[`Py<T>`]bind().(py).getattrrust-analyzer cargo pyo3 0.28.0 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]getattr().("Loop")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..castrust-analyzer cargo pyo3 0.28.0 instance/impl#[`Bound<'py, T>`]cast().::<PyTyperust-analyzer cargo pyo3 0.28.0 types/typeobject/PyType#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 40 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 41 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 42 | |
| 43 | tokiorust-analyzer cargo tokio 1.49.0 crate/::timerust-analyzer cargo tokio 1.49.0 time/::sleeprust-analyzer cargo tokio 1.49.0 time/sleep/sleep().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(1)).rust-analyzer cargo tokio 1.49.0 time/sleep/impl#[Sleep][Future]poll().awaitrust-analyzer cargo tokio 1.49.0 time/sleep/impl#[Sleep][Future]poll().; |
| 44 | |
| 45 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("test test_tokio_current_thread_uvloop ... ok"); |
| 46 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 47 | }) |
| 48 | }) |
| 49 | } |
| 50 | |
| 51 | #[cfg(target_os = "windows")] |
| 52 | fn main() {} |