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:
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 class for such a purpose?