except socket.error: print('connection error') #Maquina 1 if maq1.ps != '': try: serialized = header_maq1_ps.make_header_cs() print 'SENDING :', serialized s.sendall(serialized) # Look for the response out = s.recv(10024) maq1.ps_result = out print 'received "%s"' % out finally: print '' if maq1.df != '': try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: s.connect((ip, pm1)) except socket.error: print('connection error')