From bd1119e82ff9f4bd8835ed6d3934f156a6da8b23 Mon Sep 17 00:00:00 2001 From: rcoh Date: Fri, 28 Jan 2011 16:24:21 -0500 Subject: Fixed TCPInput bug. --- inputs/TCPInput.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'inputs') diff --git a/inputs/TCPInput.py b/inputs/TCPInput.py index 17ea7e6..51a6677 100644 --- a/inputs/TCPInput.py +++ b/inputs/TCPInput.py @@ -4,6 +4,7 @@ from operationscore.Input import * import socket, json, time import logging as main_log import string +from select import select class TCPInput(Input): """TCPInput is a input to receive input on a TCP port. In its current incarnation, it parses @@ -20,9 +21,20 @@ class TCPInput(Input): self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.bind((self.HOST, self.PORT)) self.sock.listen(1) - (self.conn, self.address) = self.sock.accept() + + isreadable=select([self.sock],[],[], 0)[0] + self.conn = None + if isreadable: + (self.conn, self.address) = self.sock.accept() def sensingLoop(self): + if self.conn == None: + isreadable=select([self.sock],[],[], 0)[0] + if isreadable: + (self.conn, self.address) = self.sock.accept() + else: + return + data = self.conn.recv(self.BUFFER_SIZE) main_log.debug('Incoming data', data) -- cgit v1.2.3