<commit_before>import sys
import threading
import httplib
import time
import json
import asyncore
import socket
import os
import logging
import random
import multiprocessing
from multiprocessing import Queue

# Setup logging redirection
logger = logging.getLogger('bridge')
hdlr = logging.FileHandler('./bridge.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr) 
logger.setLevel(logging.INFO)

# Global ref to the singleton bridge server running on this node
bridgeServer = None
blockingMap = {}

def modExp(self, a, b, m):
	a %= m
	ret = None
	if b == 0:
		ret = 1
	elif b % 2:
		ret = a * modExp(a, b-1, m)
	else:
		ret = modExp(a, b//2, m)
		ret *= ret
	return (ret % m)

class BridgeHandler((SocketServer.BaseRequestHandler):

	def __init__(self, request, client_address, server):
		SocketServer.BaseRequestHandler.__init__(self, request, client_address, server)

	def setup(self):
		print >> sys.stderr, "Handler initialized for address: " + str(client_address)
		logger.info("Handler initialized")
        return SocketServer.BaseRequestHandler.setup(self)

	def handle(self):
		global bridgeServer
		global blockingMap
		length = int(self.request.recv(4))
		print >> sys.stderr, "received: " + str(length)
		data = self.request.recv(1024)
		print >> sys.stderr, "received: " + str(data)

		# Check to see if this is key data or an interest
		if (not (client_address in self.stage.keyMap)):	
			print >> "generating and returning key..."

			mod = bridgeServer.mod
			gen = bridgeServer.gen
			bits = bridgeServer.bits
			rand = random.randint(0, mod)
			power = (rand % (2 ** bits))
			ours = modExp(gen, power, mod)

			# Send our half back on down<commit_msg>Whoops<commit_after>import sys
import threading
import httplib
import time
import json
import asyncore
import socket
import os
import logging
import random
import multiprocessing
from multiprocessing import Queue

# Setup logging redirection
logger = logging.getLogger('bridge')
hdlr = logging.FileHandler('./bridge.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr) 
logger.setLevel(logging.INFO)

# Global ref to the singleton bridge server running on this node
bridgeServer = None
blockingMap = {}

def modExp(self, a, b, m):
	a %= m
	ret = None
	if b == 0:
		ret = 1
	elif b % 2:
		ret = a * modExp(a, b-1, m)
	else:
		ret = modExp(a, b//2, m)
		ret *= ret
	return (ret % m)

class BridgeHandler(SocketServer.BaseRequestHandler):

	def __init__(self, request, client_address, server):
		SocketServer.BaseRequestHandler.__init__(self, request, client_address, server)

	def setup(self):
		print >> sys.stderr, "Handler initialized for address: " + str(client_address)
		logger.info("Handler initialized")
        return SocketServer.BaseRequestHandler.setup(self)

	def handle(self):
		global bridgeServer
		global blockingMap
		length = int(self.request.recv(4))
		print >> sys.stderr, "received: " + str(length)
		data = self.request.recv(1024)
		print >> sys.stderr, "received: " + str(data)

		# Check to see if this is key data or an interest
		if (not (client_address in self.stage.keyMap)):	
			print >> "generating and returning key..."

			mod = bridgeServer.mod
			gen = bridgeServer.gen
			bits = bridgeServer.bits
			rand = random.randint(0, mod)
			power = (rand % (2 ** bits))
			ours = modExp(gen, power, mod)

			# Send our half back on down
{'fraction_non_alphanumeric': 0.11388410786001148, 'fraction_numerical': 0.0068846815834767644, 'mean_word_length': 4.291350531107739, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '3545724', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1111, 'n_words': 343}