mirror of
https://github.com/wez/wezterm.git
synced 2024-11-26 16:34:23 +03:00
pty: update async example for more recent smol release
This commit is contained in:
parent
85bfc7de6f
commit
233adb5fe9
161
Cargo.lock
generated
161
Cargo.lock
generated
@ -148,6 +148,16 @@ version = "0.5.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
|
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-barrier"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "04b50fe84d0aea412a4e751cb01b9e26e2be533b2708607c2a2a739b192ee45a"
|
||||||
|
dependencies = [
|
||||||
|
"async-mutex",
|
||||||
|
"event-listener",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-channel"
|
name = "async-channel"
|
||||||
version = "1.4.2"
|
version = "1.4.2"
|
||||||
@ -168,11 +178,21 @@ dependencies = [
|
|||||||
"async-task 4.0.2",
|
"async-task 4.0.2",
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"futures-lite 1.8.0",
|
"futures-lite",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"vec-arena",
|
"vec-arena",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-fs"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e3572236ba37147ca2b674a0bd5afd20aec0cd925ab125ab6fad6543960f9002"
|
||||||
|
dependencies = [
|
||||||
|
"blocking",
|
||||||
|
"futures-lite",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-global-executor"
|
name = "async-global-executor"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
@ -181,7 +201,7 @@ checksum = "fefeb39da249f4c33af940b779a56723ce45809ef5c54dad84bb538d4ffb6d9e"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"async-executor",
|
"async-executor",
|
||||||
"async-io",
|
"async-io",
|
||||||
"futures-lite 1.8.0",
|
"futures-lite",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
@ -194,16 +214,28 @@ checksum = "b5bfd63f6fc8fd2925473a147d3f4d252c712291efdde0d7057b25146563402c"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"futures-lite 1.8.0",
|
"futures-lite",
|
||||||
"log",
|
"log",
|
||||||
"nb-connect",
|
"nb-connect",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parking 2.0.0",
|
"parking",
|
||||||
"polling",
|
"polling",
|
||||||
"vec-arena",
|
"vec-arena",
|
||||||
"waker-fn",
|
"waker-fn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-lock"
|
||||||
|
version = "2.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "76000290eb3c67dfe4e2bdf6b6155847f8e16fc844377a7bd0b5e97622656362"
|
||||||
|
dependencies = [
|
||||||
|
"async-barrier",
|
||||||
|
"async-mutex",
|
||||||
|
"async-rwlock",
|
||||||
|
"async-semaphore",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-mutex"
|
name = "async-mutex"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@ -213,6 +245,53 @@ dependencies = [
|
|||||||
"event-listener",
|
"event-listener",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-net"
|
||||||
|
version = "1.4.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "14a5335056541826f855bf95b936df9788adbacf94b15ef7104029f7fff3e82a"
|
||||||
|
dependencies = [
|
||||||
|
"async-io",
|
||||||
|
"blocking",
|
||||||
|
"fastrand",
|
||||||
|
"futures-lite",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-process"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0bb915df28b8309139bd9c9c700d84c20e5c21385d05378caa84912332d0f6a1"
|
||||||
|
dependencies = [
|
||||||
|
"async-io",
|
||||||
|
"blocking",
|
||||||
|
"cfg-if",
|
||||||
|
"event-listener",
|
||||||
|
"futures-lite",
|
||||||
|
"once_cell",
|
||||||
|
"signal-hook",
|
||||||
|
"winapi 0.3.9",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-rwlock"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "261803dcc39ba9e72760ba6e16d0199b1eef9fc44e81bffabbebb9f5aea3906c"
|
||||||
|
dependencies = [
|
||||||
|
"async-mutex",
|
||||||
|
"event-listener",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-semaphore"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "538c756e85eb6ffdefaec153804afb6da84b033e2e5ec3e9d459c34b4bf4d3f6"
|
||||||
|
dependencies = [
|
||||||
|
"event-listener",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-std"
|
name = "async-std"
|
||||||
version = "1.6.5"
|
version = "1.6.5"
|
||||||
@ -222,12 +301,12 @@ dependencies = [
|
|||||||
"async-global-executor",
|
"async-global-executor",
|
||||||
"async-io",
|
"async-io",
|
||||||
"async-mutex",
|
"async-mutex",
|
||||||
"blocking 1.0.0",
|
"blocking",
|
||||||
"crossbeam-utils 0.7.2",
|
"crossbeam-utils 0.7.2",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-io",
|
"futures-io",
|
||||||
"futures-lite 1.8.0",
|
"futures-lite",
|
||||||
"gloo-timers",
|
"gloo-timers",
|
||||||
"kv-log-macro",
|
"kv-log-macro",
|
||||||
"log",
|
"log",
|
||||||
@ -250,12 +329,6 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "async-task"
|
|
||||||
version = "3.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-task"
|
name = "async-task"
|
||||||
version = "4.0.2"
|
version = "4.0.2"
|
||||||
@ -368,20 +441,6 @@ version = "0.1.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
|
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "blocking"
|
|
||||||
version = "0.4.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d2468ff7bf85066b4a3678fede6fe66db31846d753ff0adfbfab2c6a6e81612b"
|
|
||||||
dependencies = [
|
|
||||||
"async-channel",
|
|
||||||
"atomic-waker",
|
|
||||||
"futures-lite 0.1.11",
|
|
||||||
"once_cell",
|
|
||||||
"parking 1.0.6",
|
|
||||||
"waker-fn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blocking"
|
name = "blocking"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
@ -391,7 +450,7 @@ dependencies = [
|
|||||||
"async-channel",
|
"async-channel",
|
||||||
"atomic-waker",
|
"atomic-waker",
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"futures-lite 1.8.0",
|
"futures-lite",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"waker-fn",
|
"waker-fn",
|
||||||
]
|
]
|
||||||
@ -1238,21 +1297,6 @@ version = "0.3.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789"
|
checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-lite"
|
|
||||||
version = "0.1.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "97999970129b808f0ccba93211201d431fcc12d7e1ffae03a61b5cedd1a7ced2"
|
|
||||||
dependencies = [
|
|
||||||
"fastrand",
|
|
||||||
"futures-core",
|
|
||||||
"futures-io",
|
|
||||||
"memchr",
|
|
||||||
"parking 2.0.0",
|
|
||||||
"pin-project-lite",
|
|
||||||
"waker-fn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-lite"
|
name = "futures-lite"
|
||||||
version = "1.8.0"
|
version = "1.8.0"
|
||||||
@ -1263,7 +1307,7 @@ dependencies = [
|
|||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-io",
|
"futures-io",
|
||||||
"memchr",
|
"memchr",
|
||||||
"parking 2.0.0",
|
"parking",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"waker-fn",
|
"waker-fn",
|
||||||
]
|
]
|
||||||
@ -2330,12 +2374,6 @@ dependencies = [
|
|||||||
"syn 1.0.42",
|
"syn 1.0.42",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "parking"
|
|
||||||
version = "1.0.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6cb300f271742d4a2a66c01b6b2fa0c83dfebd2e0bf11addb879a3547b4ed87c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking"
|
name = "parking"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
@ -3209,23 +3247,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smol"
|
name = "smol"
|
||||||
version = "0.1.18"
|
version = "1.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5"
|
checksum = "7ca2722989073e89917a575862fb49dba3321af152f0cf4a4164d9482aabdf28"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-task 3.0.0",
|
"async-channel",
|
||||||
"blocking 0.4.7",
|
"async-executor",
|
||||||
"concurrent-queue",
|
"async-fs",
|
||||||
"fastrand",
|
"async-io",
|
||||||
"futures-io",
|
"async-lock",
|
||||||
"futures-util",
|
"async-net",
|
||||||
"libc",
|
"async-process",
|
||||||
|
"blocking",
|
||||||
|
"futures-lite",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"scoped-tls",
|
|
||||||
"slab",
|
|
||||||
"socket2",
|
|
||||||
"wepoll-sys-stjepang",
|
|
||||||
"winapi 0.3.9",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -39,5 +39,5 @@ winapi = { version = "0.3", features = [
|
|||||||
]}
|
]}
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
smol = "0.1"
|
smol = "1.2"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
@ -6,7 +6,7 @@ use portable_pty::{native_pty_system, CommandBuilder, PtySize};
|
|||||||
// in an asynchronous application.
|
// in an asynchronous application.
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
smol::run(async {
|
smol::block_on(async {
|
||||||
let pty_system = native_pty_system();
|
let pty_system = native_pty_system();
|
||||||
|
|
||||||
let pair = pty_system.openpty(PtySize {
|
let pair = pty_system.openpty(PtySize {
|
||||||
@ -24,7 +24,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// file handles which is important to avoid deadlock
|
// file handles which is important to avoid deadlock
|
||||||
// when waiting for the child process!
|
// when waiting for the child process!
|
||||||
let slave = pair.slave;
|
let slave = pair.slave;
|
||||||
let mut child = smol::blocking!(slave.spawn_command(cmd))?;
|
let mut child = smol::unblock(move || slave.spawn_command(cmd)).await?;
|
||||||
|
|
||||||
let reader = pair.master.try_clone_reader()?;
|
let reader = pair.master.try_clone_reader()?;
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// waiting for a future child that will never be spawned.
|
// waiting for a future child that will never be spawned.
|
||||||
drop(pair.master);
|
drop(pair.master);
|
||||||
|
|
||||||
let mut lines = futures::io::BufReader::new(smol::reader(reader)).lines();
|
let mut lines = smol::io::BufReader::new(smol::Unblock::new(reader)).lines();
|
||||||
while let Some(line) = lines.next().await {
|
while let Some(line) = lines.next().await {
|
||||||
let line = line.map_err(|e| anyhow!("problem reading line: {}", e))?;
|
let line = line.map_err(|e| anyhow!("problem reading line: {}", e))?;
|
||||||
// We print with escapes escaped because the windows conpty
|
// We print with escapes escaped because the windows conpty
|
||||||
@ -56,9 +56,10 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// its output from making it into the pty.
|
// its output from making it into the pty.
|
||||||
println!(
|
println!(
|
||||||
"child status: {:?}",
|
"child status: {:?}",
|
||||||
smol::blocking!(child
|
smol::unblock(move || child
|
||||||
.wait()
|
.wait()
|
||||||
.map_err(|e| anyhow!("waiting for child: {}", e)))?
|
.map_err(|e| anyhow!("waiting for child: {}", e)))
|
||||||
|
.await?
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user