Okay, I think I've got it now. This: http://twistedmatrix.com/projects/core/documentation/howto/threading.html combined with this: http://mail.python.org/pipermail/python-list/2004-February/209632.html contained some details I was woefully ignorant of. --- Lenny G Arbage <alengarbage@yahoo.com> wrote:
Where can I find examples or instructions on combining the reactor with [command-line] user interaction? I've been searching every resource I can, and know it must be possible based on threads like this one:
http://twistedmatrix.com/pipermail/twisted-python/2005-June/010625.html
. I /can/ block on a call made from within the reactor while waiting for user's raw_input, but that doesn't allow me to give live feedback to the user from incoming status messages, and might cause problems if a large number of status messages arrive while the user is 'away'. All the example clients I can find inside of twisted are not [user-] interactive (ftpclient, echoclient, simpleclient, etc). Am I looking in the wrong place? Have I missed a howto?
Specifically I have a server that takes commands via a protocol I define and a client that sends commands to the server. The commands on the server take some time (on the order of 20 seconds to many minutes) to complete or error out. Once they do, status is sent back to the client, i.e., the user can issue many commands that are concurrently 'pending', completing when the server sends back status.
I've started by running the client reactor in a thread, and then using the main thread to get input from the user. Am I making this more difficult than it needs to be? Is there some way to integrate user action (keyboard input) as events into the reactor's event model? Or is there a better approach?
__________________________________________ Yahoo! DSL Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com