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

Why are stdin actually blocks and how to make it truly non-blocking? #709

Closed
katyo opened this issue Oct 18, 2018 · 2 comments
Closed

Why are stdin actually blocks and how to make it truly non-blocking? #709

katyo opened this issue Oct 18, 2018 · 2 comments
Labels
T-docs Topic: documentation

Comments

@katyo
Copy link

katyo commented Oct 18, 2018

Version

termion-tokio v0.1.0
└── tokio v0.1.11
├── tokio-codec v0.1.1
│ └── tokio-io v0.1.9
├── tokio-current-thread v0.1.3
│ └── tokio-executor v0.1.5
├── tokio-executor v0.1.5 ()
├── tokio-fs v0.1.3
│ ├── tokio-io v0.1.9 (
)
│ └── tokio-threadpool v0.1.7
│ └── tokio-executor v0.1.5 ()
│ └── tokio-io v0.1.9 (
)
├── tokio-io v0.1.9 ()
├── tokio-reactor v0.1.6
│ ├── tokio-executor v0.1.5 (
)
│ └── tokio-io v0.1.9 ()
├── tokio-tcp v0.1.2
│ ├── tokio-io v0.1.9 (
)
│ └── tokio-reactor v0.1.6 ()
├── tokio-threadpool v0.1.7 (
)
├── tokio-timer v0.2.7
│ └── tokio-executor v0.1.5 ()
├── tokio-udp v0.1.2
│ ├── tokio-codec v0.1.1 (
)
│ ├── tokio-io v0.1.9 ()
│ └── tokio-reactor v0.1.6 (
)
└── tokio-uds v0.2.2
├── tokio-io v0.1.9 ()
└── tokio-reactor v0.1.6 (
)

Platform

Linux debi 4.9.0-7-amd64 #1 SMP Debian 4.9.110-3+deb9u2 (2018-08-13) x86_64 GNU/Linux

Description

When I tried to use tokio stdin (i.e. using FramedRead with self-written Decoder) it unexpectedly blocks process until any input happens.

I working with this repository: https://github.com/katyo/termion-tokio/
To reproduce you can run example: cargo run --example input.

Expected behavior: Periodical ticks happens independently from user input.
Actual behavior: No periodical ticks until any user input happens.

@carllerche carllerche added the T-docs Topic: documentation label Nov 19, 2018
@carllerche
Copy link
Member

Switching stdin / stdout to non-blocking is a process global operation and could have unintended impact on other code.

You can always switch the FD to non-blocking mode yourself, but that also means you cannot reliably use things like println! anymore.

@carllerche
Copy link
Member

I'm going to close this issue as the documentation problem is tracked in the doc-push repo (tokio-rs/doc-push#85).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-docs Topic: documentation
Projects
None yet
Development

No branches or pull requests

2 participants