[Twisted-Python] stdio.StandardIO blocks?
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: [connected] ping pong ...2 seconds ... ping pong ...2 seconds ... ping pong ... Now the user should be able to write commands in the command line, which get's 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) Cheers
On Mar 23, 2010, at 10:00 AM, Willy Lai wrote:
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)
Without a *complete* program example, we can't really tell you what might be blocking. It may be a lot of things, from some very simple problems to some very complex ones. Please see http://sscce.org/ for details on what types of examples would be useful. Based on your simple description, this really should work. If it didn't, 'twistd' wouldn't be able to log to stdout and run a server at the same time (and it definitely can, I do that every day, at least ten times). Thanks, -glyph
participants (2)
-
Glyph Lefkowitz
-
Willy Lai