Socket I/O, with select

#
# from the getternet cron job
#
import socket, select
  
sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM)

server_address = ( hsh[ 'Host'], int( hsh[ 'Port']))
sock.settimeout( 3)
try: 
    sock.connect(server_address)
except Exception as e: 
    print( "readPump: failed to connect to %s, %s " % (hsh[ 'nameUnit'], hsh[ 'Host']))
    return 

sock.sendall( argin)

inout = [ sock]

argout = ""
while 1: 
    infds, outfds, errfds = select.select( inout, [], [], 0.12)
    if len( infds) == 0:
        break
    argout = argout + sock.recv( 1024)

sock.close()