Asynchronous cmd or readline in Python

I would like to write a simple program that (1) produces output lines at the same time, and (2) accepts input from the user through the command line (via readline). (For example, think of a client in text mode. I want to be able to compose chat messages while still seeing incoming chat messages as they are received.) For this, I would like to be able to call readline asynchronously.

The Readline library explicitly supports this through a callback interface :

An alternative interface is available for simple readline (). Some applications need to alternate with keyboard I / O using I / O using files, devices, or windows, usually using the main loop to select () for different file descriptors. To meet this need, readline can also be called as a “callback” function from an event loop. Functions are available to facilitate this.

  • Is this function available through Python?
  • Can I use the Cmd class ?
+4
source share
2 answers

python readline, - . . import readline ImportError?

python cmd , .

readline , .

0

, cmd readline . , .

, , threading. ; cmd, cmds, .

0

Source: https://habr.com/ru/post/1612847/


All Articles