@@ -54,8 +54,8 @@ Here we initialize the runtime, import Python's `asyncio` library and run the gi
54
54
``` toml
55
55
# Cargo.toml dependencies
56
56
[dependencies ]
57
- pyo3 = { version = " 0.22 " }
58
- pyo3-async-runtimes = { version = " 0.22 " , features = [" attributes" , " async-std-runtime" ] }
57
+ pyo3 = { version = " 0.23 " }
58
+ pyo3-async-runtimes = { version = " 0.23 " , features = [" attributes" , " async-std-runtime" ] }
59
59
async-std = " 1.13"
60
60
```
61
61
@@ -67,9 +67,9 @@ use pyo3::prelude::*;
67
67
#[pyo3_async_runtimes:: async_std:: main]
68
68
async fn main () -> PyResult <()> {
69
69
let fut = Python :: with_gil (| py | {
70
- let asyncio = py . import_bound (" asyncio" )? ;
70
+ let asyncio = py . import (" asyncio" )? ;
71
71
// convert asyncio.sleep into a Rust Future
72
- pyo3_async_runtimes :: async_std :: into_future (asyncio . call_method1 (" sleep" , (1. into_py (py ),))? )
72
+ pyo3_async_runtimes :: async_std :: into_future (asyncio . call_method1 (" sleep" , (1. into_pyobject (py ) . unwrap ( ),))? )
73
73
})? ;
74
74
75
75
fut . await ? ;
@@ -84,8 +84,8 @@ attribute.
84
84
``` toml
85
85
# Cargo.toml dependencies
86
86
[dependencies ]
87
- pyo3 = { version = " 0.22 " }
88
- pyo3-async-runtimes = { version = " 0.22 " , features = [" attributes" , " tokio-runtime" ] }
87
+ pyo3 = { version = " 0.23 " }
88
+ pyo3-async-runtimes = { version = " 0.23 " , features = [" attributes" , " tokio-runtime" ] }
89
89
tokio = " 1.40"
90
90
```
91
91
@@ -97,9 +97,9 @@ use pyo3::prelude::*;
97
97
#[pyo3_async_runtimes:: tokio:: main]
98
98
async fn main () -> PyResult <()> {
99
99
let fut = Python :: with_gil (| py | {
100
- let asyncio = py . import_bound (" asyncio" )? ;
100
+ let asyncio = py . import (" asyncio" )? ;
101
101
// convert asyncio.sleep into a Rust Future
102
- pyo3_async_runtimes :: tokio :: into_future (asyncio . call_method1 (" sleep" , (1. into_py (py ),))? )
102
+ pyo3_async_runtimes :: tokio :: into_future (asyncio . call_method1 (" sleep" , (1. into_pyobject (py ) . unwrap ( ),))? )
103
103
})? ;
104
104
105
105
fut . await ? ;
@@ -130,8 +130,8 @@ For `async-std`:
130
130
131
131
``` toml
132
132
[dependencies ]
133
- pyo3 = { version = " 0.22 " , features = [" extension-module" ] }
134
- pyo3-async-runtimes = { version = " 0.22 " , features = [" async-std-runtime" ] }
133
+ pyo3 = { version = " 0.23 " , features = [" extension-module" ] }
134
+ pyo3-async-runtimes = { version = " 0.23 " , features = [" async-std-runtime" ] }
135
135
async-std = " 1.13"
136
136
```
137
137
@@ -140,7 +140,7 @@ For `tokio`:
140
140
``` toml
141
141
[dependencies ]
142
142
pyo3 = { version = " 0.20" , features = [" extension-module" ] }
143
- pyo3-async-runtimes = { version = " 0.22 " , features = [" tokio-runtime" ] }
143
+ pyo3-async-runtimes = { version = " 0.23 " , features = [" tokio-runtime" ] }
144
144
tokio = " 1.40"
145
145
```
146
146
@@ -240,7 +240,7 @@ use pyo3::prelude::*;
240
240
async fn main () -> PyResult <()> {
241
241
let future = Python :: with_gil (| py | -> PyResult <_ > {
242
242
// import the module containing the py_sleep function
243
- let example = py . import_bound (" example" )? ;
243
+ let example = py . import (" example" )? ;
244
244
245
245
// calling the py_sleep method like a normal function
246
246
// returns a coroutine
@@ -359,11 +359,11 @@ async fn main() -> PyResult<()> {
359
359
// PyO3 is initialized - Ready to go
360
360
361
361
let fut = Python :: with_gil (| py | -> PyResult <_ > {
362
- let asyncio = py . import_bound (" asyncio" )? ;
362
+ let asyncio = py . import (" asyncio" )? ;
363
363
364
364
// convert asyncio.sleep into a Rust Future
365
365
pyo3_async_runtimes :: async_std :: into_future (
366
- asyncio . call_method1 (" sleep" , (1. into_py (py ),))?
366
+ asyncio . call_method1 (" sleep" , (1. into_pyobject (py ) . unwrap ( ),))?
367
367
)
368
368
})? ;
369
369
@@ -434,8 +434,8 @@ name = "my_async_module"
434
434
crate-type = [" cdylib" ]
435
435
436
436
[dependencies ]
437
- pyo3 = { version = " 0.22 " , features = [" extension-module" ] }
438
- pyo3-async-runtimes = { version = " 0.22 " , features = [" tokio-runtime" ] }
437
+ pyo3 = { version = " 0.23 " , features = [" extension-module" ] }
438
+ pyo3-async-runtimes = { version = " 0.23 " , features = [" tokio-runtime" ] }
439
439
async-std = " 1.13"
440
440
tokio = " 1.40"
441
441
```
@@ -494,8 +494,8 @@ event loop before we can install the `uvloop` policy.
494
494
``` toml
495
495
[dependencies ]
496
496
async-std = " 1.13"
497
- pyo3 = " 0.22 "
498
- pyo3-async-runtimes = { version = " 0.22 " , features = [" async-std-runtime" ] }
497
+ pyo3 = " 0.23 "
498
+ pyo3-async-runtimes = { version = " 0.23 " , features = [" async-std-runtime" ] }
499
499
```
500
500
501
501
``` rust no_run
@@ -507,7 +507,7 @@ fn main() -> PyResult<()> {
507
507
pyo3 :: prepare_freethreaded_python ();
508
508
509
509
Python :: with_gil (| py | {
510
- let uvloop = py . import_bound (" uvloop" )? ;
510
+ let uvloop = py . import (" uvloop" )? ;
511
511
uvloop . call_method0 (" install" )? ;
512
512
513
513
// store a reference for the assertion
@@ -604,7 +604,7 @@ To make things a bit easier, I decided to keep most of the old API alongside the
604
604
pyo3 :: prepare_freethreaded_python ();
605
605
606
606
Python :: with_gil (| py | {
607
- let asyncio = py . import_bound (" asyncio" )? ;
607
+ let asyncio = py . import (" asyncio" )? ;
608
608
609
609
let event_loop = asyncio . call_method0 (" new_event_loop" )? ;
610
610
asyncio . call_method1 (" set_event_loop" , (& event_loop ,))? ;
0 commit comments