Asynchronous cmd or readline in Python
Question: I would like to write a simple program that both (1) produces lines of output
simultaneously, and (2) accepts input from the user via a command line (via
readline). (Think of a text-mode chat client, for example. I want to be able
to compose my chat messages while still seeing incoming chat messages as they
are received.) To accomplish this, I would like to be able to call readline
asynchronously.

The Readline library explicitly supports this, via its [callback
interface](http://www.delorie.com/gnu/docs/readline/rlman_41.html):

> An alternate interface is available to plain readline(). Some applications
> need to interleave keyboard I/O with file, device, or window system I/O,
> typically by using a main loop to select() on various file descriptors. To
> accommodate this need, readline can also be invoked as a `callback' function
> from an event loop. There are functions available to make this easy.

  * **Is this functionality available via Python?**
  * **Is it possible to use the[Cmd](https://docs.python.org/2/library/cmd.html) class for such a purpose?**


Answer: Some installations of python support the `readline` interface, some do not.
The only way to find out is via testing. Does `import readline` work or raise
and `ImportError`?

The python `cmd` module is intended for a totally diferent purpose involvivng
making your own shells and is not helpful in this context.

Even if the `readline` module is not available, a similar task could be
accomplished with threads.

