<commit_before>import random
import json

import SocketExtend as SockExt
import config as conf
import parser as p

def ping(sock):
	try:
		rand = random.randint(1, 99999)
		data = {'request':'ping', 'contents': {'value':rand}}
		SockExt.send_msg(sock, json.dumps(data))
		result = json.loads(SockExt.recv_msg(sock))
	
		if result['return'] == rand:
			return True
		else:
			return False

	except Exception as e:	
		print "Exception while pinging: ", e
		return False

def multiping(port, auths=[]):
	result = True
	for a_ip in auths:	
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		#s.settimeout(120.0)
		sock.connect((a_ip, int(port)))
		if not ping(sock):
			result = False
		sock.shutdown(socket.SHUT_RDWR)
		sock.close()
	
	return result

def alive(port, machines=[]):
	attempted = 0

	success = False
	while (attempted < conf.tries):
		try:
			if utilities.multiping(port, machines):
				success = True
				break
		except Exception as e:
			attempted += 1

	return success<commit_msg>Clean up, comments, liveness checking, robust data transfer<commit_after>import random
import json

import SocketExtend as SockExt
import config as conf
import parser as p

def ping(sock):
	try:
		rand = random.randint(1, 99999)
		data = {'request':'ping', 'contents': {'value':rand}}
		SockExt.send_msg(sock, json.dumps(data))
		result = json.loads(SockExt.recv_msg(sock))
	
		if result['return'] == rand:
			return True
		else:
			return False

	except Exception as e:	
		print "Exception while pinging: ", e
		return False

def multiping(port, auths=[]):
	result = True
	for a_ip in auths:	
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		#s.settimeout(120.0)
		sock.connect((a_ip, int(port)))
		if not ping(sock):
			result = False
		sock.shutdown(socket.SHUT_RDWR)
		sock.close()
	
	return result

def alive(port, machines=[]):
	attempted = 0

	success = False
	while (attempted < conf.tries):
		try:
			if utilities.multiping(port, machines):
				success = True
				print "hey"
				break
		except Exception as e:
			print "ouups"
			attempted += 1

	return success
{'fraction_non_alphanumeric': 0.11835170100622903, 'fraction_numerical': 0.011499760421657882, 'mean_word_length': 3.9129411764705884, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '646238', 'n_tokens_mistral': 835, 'n_tokens_neox': 720, 'n_words': 206}