Debian Codegraph @

pytests/test_async_std_uvloop.rs

raw symbols SCIP
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 Pythonrust-analyzer cargo pyo3 0.28.0 marker/Python#::initializerust-analyzer cargo pyo3 0.28.0 marker/impl#[`Python<'_>`]initialize().();
5
6 Pythonrust-analyzer cargo pyo3 0.28.0 marker/Python#::attachrust-analyzer cargo pyo3 0.28.0 marker/impl#[`Python<'_>`]attach().(|py| {
7 // uvloop not supported on the free-threaded build yet
8 // https://github.com/MagicStack/uvloop/issues/642
9 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().;
10 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().;
11 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(). {
12 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(());
13 }
14
15 // uvloop not yet supported on 3.14
16 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) {
17 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(());
18 }
19
20 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().;
21 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().;
22
23 // store a reference for the assertion
24 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().();
25
26 pyo3_async_runtimesrust-analyzer cargo pyo3-async-runtimes 0.28.0 crate/::async_stdrust-analyzer cargo pyo3-async-runtimes 0.28.0 async_std/::runrust-analyzer cargo pyo3-async-runtimes 0.28.0 async_std/run().(py, async move {
27 // verify that we are on a uvloop.Loop
28 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#<()> {
29 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/::async_stdrust-analyzer cargo pyo3-async-runtimes 0.28.0 async_std/::get_current_looprust-analyzer cargo pyo3-async-runtimes 0.28.0 async_std/get_current_loop().(py)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
30 .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().);
31 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
32 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
33
34 async_stdrust-analyzer cargo async-std 1.13.2 crate/::taskrust-analyzer cargo async-std 1.13.2 task/::sleeprust-analyzer cargo async-std 1.13.2 task/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 core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
35
36 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("test test_async_std_uvloop ... ok");
37 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
38 })
39 })
40 }
41
42 #[cfg(target_os = "windows")]
43 fn main() {}