@@ -50,8 +50,8 @@ Here we initialize the runtime, import Python's `asyncio` library and run the gi
5050``` toml
5151# Cargo.toml dependencies
5252[dependencies ]
53- pyo3 = { version = " 0.25 " }
54- pyo3-async-runtimes = { version = " 0.25 " , features = [" attributes" , " async-std-runtime" ] }
53+ pyo3 = { version = " 0.26 " }
54+ pyo3-async-runtimes = { version = " 0.26 " , features = [" attributes" , " async-std-runtime" ] }
5555async-std = " 1.13"
5656```
5757
@@ -62,10 +62,10 @@ use pyo3::prelude::*;
6262
6363#[pyo3_async_runtimes:: async_std:: main]
6464async fn main () -> PyResult <()> {
65- let fut = Python :: with_gil (| py | {
65+ let fut = Python :: attach (| py | {
6666 let asyncio = py . import (" asyncio" )? ;
6767 // convert asyncio.sleep into a Rust Future
68- pyo3_async_runtimes :: async_std :: into_future (asyncio . call_method1 (" sleep" , (1. into_pyobject ( py ) . unwrap () ,))? )
68+ pyo3_async_runtimes :: async_std :: into_future (asyncio . call_method1 (" sleep" , (1 ,))? )
6969 })? ;
7070
7171 fut . await ? ;
@@ -80,8 +80,8 @@ attribute.
8080``` toml
8181# Cargo.toml dependencies
8282[dependencies ]
83- pyo3 = { version = " 0.25 " }
84- pyo3-async-runtimes = { version = " 0.25 " , features = [" attributes" , " tokio-runtime" ] }
83+ pyo3 = { version = " 0.26 " }
84+ pyo3-async-runtimes = { version = " 0.26 " , features = [" attributes" , " tokio-runtime" ] }
8585tokio = " 1.40"
8686```
8787
@@ -92,10 +92,10 @@ use pyo3::prelude::*;
9292
9393#[pyo3_async_runtimes:: tokio:: main]
9494async fn main () -> PyResult <()> {
95- let fut = Python :: with_gil (| py | {
95+ let fut = Python :: attach (| py | {
9696 let asyncio = py . import (" asyncio" )? ;
9797 // convert asyncio.sleep into a Rust Future
98- pyo3_async_runtimes :: tokio :: into_future (asyncio . call_method1 (" sleep" , (1. into_pyobject ( py ) . unwrap () ,))? )
98+ pyo3_async_runtimes :: tokio :: into_future (asyncio . call_method1 (" sleep" , (1 ,))? )
9999 })? ;
100100
101101 fut . await ? ;
@@ -126,17 +126,17 @@ For `async-std`:
126126
127127``` toml
128128[dependencies ]
129- pyo3 = { version = " 0.25 " , features = [" extension-module" ] }
130- pyo3-async-runtimes = { version = " 0.25 " , features = [" async-std-runtime" ] }
129+ pyo3 = { version = " 0.26 " , features = [" extension-module" ] }
130+ pyo3-async-runtimes = { version = " 0.26 " , features = [" async-std-runtime" ] }
131131async-std = " 1.13"
132132```
133133
134134For ` tokio ` :
135135
136136``` toml
137137[dependencies ]
138- pyo3 = { version = " 0.25 " , features = [" extension-module" ] }
139- pyo3-async-runtimes = { version = " 0.25 " , features = [" tokio-runtime" ] }
138+ pyo3 = { version = " 0.26 " , features = [" extension-module" ] }
139+ pyo3-async-runtimes = { version = " 0.26 " , features = [" tokio-runtime" ] }
140140tokio = " 1.40"
141141```
142142
@@ -234,7 +234,7 @@ use pyo3::prelude::*;
234234
235235#[pyo3_async_runtimes:: tokio:: main]
236236async fn main () -> PyResult <()> {
237- let future = Python :: with_gil (| py | -> PyResult <_ > {
237+ let future = Python :: attach (| py | -> PyResult <_ > {
238238 // import the module containing the py_sleep function
239239 let example = py . import (" example" )? ;
240240
@@ -354,12 +354,12 @@ use pyo3::prelude::*;
354354async fn main () -> PyResult <()> {
355355 // PyO3 is initialized - Ready to go
356356
357- let fut = Python :: with_gil (| py | -> PyResult <_ > {
357+ let fut = Python :: attach (| py | -> PyResult <_ > {
358358 let asyncio = py . import (" asyncio" )? ;
359359
360360 // convert asyncio.sleep into a Rust Future
361361 pyo3_async_runtimes :: async_std :: into_future (
362- asyncio . call_method1 (" sleep" , (1. into_pyobject ( py ) . unwrap () ,))?
362+ asyncio . call_method1 (" sleep" , (1 ,))?
363363 )
364364 })? ;
365365
@@ -430,8 +430,8 @@ name = "my_async_module"
430430crate-type = [" cdylib" ]
431431
432432[dependencies ]
433- pyo3 = { version = " 0.25 " , features = [" extension-module" ] }
434- pyo3-async-runtimes = { version = " 0.25 " , features = [" tokio-runtime" ] }
433+ pyo3 = { version = " 0.26 " , features = [" extension-module" ] }
434+ pyo3-async-runtimes = { version = " 0.26 " , features = [" tokio-runtime" ] }
435435async-std = " 1.13"
436436tokio = " 1.40"
437437```
@@ -490,8 +490,8 @@ event loop before we can install the `uvloop` policy.
490490``` toml
491491[dependencies ]
492492async-std = " 1.13"
493- pyo3 = " 0.25 "
494- pyo3-async-runtimes = { version = " 0.25 " , features = [" async-std-runtime" ] }
493+ pyo3 = " 0.26 "
494+ pyo3-async-runtimes = { version = " 0.26 " , features = [" async-std-runtime" ] }
495495```
496496
497497``` rust no_run
@@ -500,18 +500,18 @@ pyo3-async-runtimes = { version = "0.25", features = ["async-std-runtime"] }
500500use pyo3 :: {prelude :: * , types :: PyType };
501501
502502fn main () -> PyResult <()> {
503- pyo3 :: prepare_freethreaded_python ();
503+ Python :: initialize ();
504504
505- Python :: with_gil (| py | {
505+ Python :: attach (| py | {
506506 let uvloop = py . import (" uvloop" )? ;
507507 uvloop . call_method0 (" install" )? ;
508508
509509 // store a reference for the assertion
510- let uvloop = PyObject :: from ( uvloop );
510+ let uvloop : Py < PyAny > = uvloop . into ( );
511511
512512 pyo3_async_runtimes :: async_std :: run (py , async move {
513513 // verify that we are on a uvloop.Loop
514- Python :: with_gil (| py | -> PyResult <()> {
514+ Python :: attach (| py | -> PyResult <()> {
515515 assert! (uvloop
516516 . bind (py )
517517 . getattr (" Loop" )?
0 commit comments