You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: Version bumps and package naming in CI and README (#9)
* Version bumps and package naming in CI and README
* link
* more naming.
* Update README.md
Co-authored-by: David Hewitt <[email protected]>
* more links
---------
Co-authored-by: David Hewitt <[email protected]>
***This is a fork of [`pyo3-asyncio`](https://github.com/awestlake87/pyo3-asyncio/) to deliver compatibility for PyO3 0.21. This may be the base for a permanent fork in the future, depending on the status of the original `pyo3-asyncio` maintainer.***
@@ -323,7 +324,7 @@ implementations _prefer_ control over the main thread, this can still make some
323
324
324
325
Because Python needs to control the main thread, we can't use the convenient proc macros from Rust
325
326
runtimes to handle the `main` function or `#[test]` functions. Instead, the initialization for PyO3 has to be done from the `main` function and the main
326
-
thread must block on [`pyo3_async_runtimes::run_forever`](https://docs.rs/pyo3-asyncio/latest/pyo3_asyncio/fn.run_forever.html) or [`pyo3_async_runtimes::async_std::run_until_complete`](https://docs.rs/pyo3-asyncio/latest/pyo3_asyncio/async_std/fn.run_until_complete.html).
327
+
thread must block on [`pyo3_async_runtimes::run_forever`](https://docs.rs/pyo3-asyncio/latest/pyo3_async_runtimes/fn.run_forever.html) or [`pyo3_async_runtimes::async_std::run_until_complete`](https://docs.rs/pyo3-asyncio/latest/pyo3_async_runtimes/async_std/fn.run_until_complete.html).
327
328
328
329
Because we have to block on one of those functions, we can't use [`#[async_std::main]`](https://docs.rs/async-std/latest/async_std/attr.main.html) or [`#[tokio::main]`](https://docs.rs/tokio/1.1.0/tokio/attr.main.html)
329
330
since it's not a good idea to make long blocking calls during an async function.
@@ -423,7 +424,7 @@ Python allows you to use alternatives to the default `asyncio` event loop. One
423
424
popular alternative is `uvloop`. In `v0.13` using non-standard event loops was
424
425
a bit of an ordeal, but in `v0.14` it's trivial.
425
426
426
-
#### Using `uvloop` in a PyO3 Asyncio Native Extensions
427
+
#### Using `uvloop` in a PyO3 Native Extensions
427
428
428
429
```toml
429
430
# Cargo.toml
@@ -433,10 +434,10 @@ name = "my_async_module"
433
434
crate-type = ["cdylib"]
434
435
435
436
[dependencies]
436
-
pyo3 = { version = "0.20", features = ["extension-module"] }
437
-
pyo3-asyncio-0-21 = { version = "0.20", features = ["tokio-runtime"] }
438
-
async-std = "1.9"
439
-
tokio = "1.9"
437
+
pyo3 = { version = "0.22", features = ["extension-module"] }
438
+
pyo3-async-runtimes = { version = "0.22", features = ["tokio-runtime"] }
439
+
async-std = "1.13"
440
+
tokio = "1.40"
440
441
```
441
442
442
443
```rust
@@ -492,9 +493,9 @@ event loop before we can install the `uvloop` policy.
492
493
493
494
```toml
494
495
[dependencies]
495
-
async-std = "1.9"
496
-
pyo3 = "0.20"
497
-
pyo3-asyncio-0-21 = { version = "0.20", features = ["async-std-runtime"] }
496
+
async-std = "1.13"
497
+
pyo3 = "0.22"
498
+
pyo3-async-runtimes = { version = "0.22", features = ["async-std-runtime"] }
498
499
```
499
500
500
501
```rust no_run
@@ -534,8 +535,8 @@ fn main() -> PyResult<()> {
534
535
535
536
### Additional Information
536
537
537
-
- Managing event loop references can be tricky with pyo3-asyncio. See [Event Loop References and ContextVars](https://awestlake87.github.io/pyo3-asyncio/master/doc/pyo3_asyncio/#event-loop-references-and-contextvars) in the API docs to get a better intuition for how event loop references are managed in this library.
538
-
- Testing pyo3-asyncio libraries and applications requires a custom test harness since Python requires control over the main thread. You can find a testing guide in the [API docs for the `testing` module](https://awestlake87.github.io/pyo3-asyncio/master/doc/pyo3_asyncio/testing)
538
+
- Managing event loop references can be tricky with pyo3-async-runtimes. See [Event Loop References and ContextVars](https://awestlake87.github.io/pyo3-asyncio/master/doc/pyo3_async_runtimes/#event-loop-references-and-contextvars) in the API docs to get a better intuition for how event loop references are managed in this library.
539
+
- Testing pyo3-asyncio libraries and applications requires a custom test harness since Python requires control over the main thread. You can find a testing guide in the [API docs for the `testing` module](https://awestlake87.github.io/pyo3-asyncio/master/doc/pyo3_async_runtimes/testing)
539
540
540
541
## Migration Guide
541
542
@@ -547,7 +548,7 @@ Well, a lot actually. There were some pretty major flaws in the initialization b
547
548
548
549
To make things a bit easier, I decided to keep most of the old API alongside the new one (with some deprecation warnings to encourage users to move away from it). It should be possible to use the `v0.13` API alongside the newer `v0.14` API, which should allow you to upgrade your application piecemeal rather than all at once.
549
550
550
-
**Before you get started, I personally recommend taking a look at [Event Loop References and ContextVars](https://awestlake87.github.io/pyo3-asyncio/master/doc/pyo3_asyncio/#event-loop-references-and-contextvars) in order to get a better grasp on the motivation behind these changes and the nuance involved in using the new conversions.**
551
+
**Before you get started, I personally recommend taking a look at [Event Loop References and ContextVars](https://awestlake87.github.io/pyo3-asyncio/master/doc/pyo3_async_runtimes/#event-loop-references-and-contextvars) in order to get a better grasp on the motivation behind these changes and the nuance involved in using the new conversions.**
551
552
552
553
### 0.14 Highlights
553
554
@@ -635,7 +636,7 @@ To make things a bit easier, I decided to keep most of the old API alongside the
635
636
```
636
637
637
638
4. Replace conversions with their newer counterparts.
638
-
> You may encounter some issues regarding the usage of `get_running_loop` vs `get_event_loop`. For more details on these newer conversions and how they should be used see [Event Loop References and ContextVars](https://awestlake87.github.io/pyo3-asyncio/master/doc/pyo3_asyncio/#event-loop-references-and-contextvars).
639
+
> You may encounter some issues regarding the usage of `get_running_loop` vs `get_event_loop`. For more details on these newer conversions and how they should be used see [Event Loop References and ContextVars](https://awestlake87.github.io/pyo3-asyncio/master/doc/pyo3_async_runtimes/#event-loop-references-and-contextvars).
639
640
- Replace `pyo3_async_runtimes::into_future` with `pyo3_async_runtimes::<runtime>::into_future`
640
641
- Replace `pyo3_async_runtimes::<runtime>::into_coroutine` with `pyo3_async_runtimes::<runtime>::future_into_py`
641
642
- Replace `pyo3_async_runtimes::get_event_loop` with `pyo3_async_runtimes::<runtime>::get_current_loop`
0 commit comments