[Twisted-Python] example stdin handling client that supports readline?

Ellers andrew at ellerton.net
Sun May 23 14:24:37 EDT 2004

Dear All,
I'd like to write a command-line shell-like interface to an in-house database service we have.

The DB service provides a socket-based API with messages like

	0001-SQL-select * from customer|

(where | is a 0x00 char)

The server responds with messages likt


I've got the basics going OK.
And in a separate script I've got a basic shell-like program going, complete with readline support.

It looks a bit like:

	mysh$ select * from customer
	[would send select statement now]


Question: how do I integrate stdin or command-driven input into the client code?

That is, because the server reactor object has control of the process, I don't see how I get read input from stdin?

I notice that there is a class


that provides a file descriptor wrapper around stdin etc.

This looks good, but I'm not sure how to connect this with the cool readline functionality, which seems to block and take care of all handling of stdin?

Is there an example of this sort of script out there?
I'm *sure* this sort of thing has been done 100 times before!

Thanks for any tips :)

More information about the Twisted-Python mailing list