Non-Blocking Reads: Clearing stdin in Python.

It turns out that clearing stdin is made easy with Python’s select module. We can use the that module’s functionality to poll input streams to test whether I/O operations will block program flow. If you’re just interested in the code, here’s the Gist. Otherwise, let’s work through it.

»
Author's profile picture @dsclose on linux and python