Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In example to demonstrate channels use same key in "get" command, that was used in "set" command. #577

Closed
sateeshkumarb opened this issue May 29, 2021 · 0 comments

Comments

@sateeshkumarb
Copy link
Contributor

sateeshkumarb commented May 29, 2021

Running below client code that has been developed to demonstrate the use of channels results in below output.
(saving the code in file client.rs)

$cargo run --bin client
....
GOT = Ok(Ok(None))
GOT = Ok(Ok(()))

The output is correct but it doesn't clearly demonstrate the intent of the example. This happens because the set is done on the key foo in task t2 (https://github.com/tokio-rs/website/blob/master/tutorial-code/channels/src/main.rs#L70) but where as the key queried in task t1 (https://github.com/tokio-rs/website/blob/master/tutorial-code/channels/src/main.rs#L53) is hello.

Due to indeterminate nature of execution of these lines:

t1.await.unwrap();
t2.await.unwrap();

I understand that the above shown output is not unexpected during the first run of the client. But in cases where the server continues to run, and I run the command cargo run --bin client querying for same key (in the example) would show the output at:

GOT = Ok(Ok(Some(b"bar")))
GOT = Ok(Ok(()))

which I think is appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants