aboutsummaryrefslogtreecommitdiff
path: root/inputs
diff options
context:
space:
mode:
Diffstat (limited to 'inputs')
-rw-r--r--inputs/TCPInput.py14
1 files changed, 13 insertions, 1 deletions
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)