[Twisted-Python] stdio.StandardIO blocks?

Willy Lai laiw at student.ethz.ch
Tue Mar 23 10:00:50 EDT 2010

Hi all

I'm new to twisted and also have not a lot of Python experience.
My problem boils down to following situation:

I have a server and a client over TCP, once the client is connected to 
the server,
the server periodically pings the client in order to check if it is 
still alive.
The client sends a response/pong back to each ping.

These messages are printed to stdout. The two consoles would then look like:

...2 seconds ...
...2 seconds ...

Now the user should be able to write commands in the command line, which 
sent to the server, without interrupting the pings. But in my case, 
while writing on the console the output stops.
The server will send a ping, but the client does not seem to receive the 
ping, since I don't get a pong on the server.
What happens at the moment I type something in the command line?

What I want, is writing stuff in the console, without interrupting the 
ping mechanism.
(The pings and pongs in my case should continue to be sent while typing 
stuff in the console)

That's how I use StandardIO:

class CommandLine(protocol.Protocol):

     def __init__(self, protocol):
         self.protocol = protocol

     def dataReceived(self, data):
         print('INPUT: %s' % (data)

class Client(protocol.DatagramProtocol):

     def __init__(self):
         # initialize command line connector
         commandLine = CommandLine(self)
         # connect member to command line output
         self.output = stdio.StandardIO(commandLine)


More information about the Twisted-Python mailing list