<commit_before>#!/usr/bin/python2
# server.py
# nroberts - 4/24/2017

import socket
import sys
import pickle
from tennis_show import TennisShow
from bridge import Bridge
import Queue
from threading import Thread

# silent
if "-s" in sys.argv:
    class TerminalBridge(Bridge):
        def init(self): pass
        def paint(self): pass
else:
    from terminal_bridge import TerminalBridge

# Only import actual bridge if we're running on the bridge
if "-p" in sys.argv:
    from pausch_bridge import PauschBridge


thread_continuing = True

def main(bridge):
    serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    serversocket.bind(('localhost', 8081))
    serversocket.listen(1) # max 1 connection
    connection, address = serversocket.accept() # block until client connects

    inqueue = Queue.Queue()
    outqueue = Queue.Queue()

    def read():
        global thread_continuing
        while thread_continuing:
            buf = connection.recv(128)
            if len(buf) > 0:
                message = pickle.loads(buf)
                outqueue.put(message)

    def write():
        global thread_continuing
        while thread_continuing:
            data = inqueue.get() # Block until we get something
            pickled = pickle.dumps(data)
            connection.send(pickled)

    readthread = Thread(target=read)
    writethread = Thread(target=write)

    show = TennisShow(bridge(), inqueue=outqueue, outqueue=inqueue)

    readthread.start()
    writethread.start()

    try:
        show.run(framerate=40)
    finally:
        global thread_continuing
        thread_continuing = False
        connection.close()
        serversocket.close()
<commit_msg>Increases amount received for server<commit_after>#!/usr/bin/python2
# server.py
# nroberts - 4/24/2017

import socket
import sys
import pickle
from tennis_show import TennisShow
from bridge import Bridge
import Queue
from threading import Thread

# silent
if "-s" in sys.argv:
    class TerminalBridge(Bridge):
        def init(self): pass
        def paint(self): pass
else:
    from terminal_bridge import TerminalBridge

# Only import actual bridge if we're running on the bridge
if "-p" in sys.argv:
    from pausch_bridge import PauschBridge


thread_continuing = True

def main(bridge):
    serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    serversocket.bind(('localhost', 8081))
    serversocket.listen(1) # max 1 connection
    connection, address = serversocket.accept() # block until client connects

    inqueue = Queue.Queue()
    outqueue = Queue.Queue()

    def read():
        global thread_continuing
        while thread_continuing:
            buf = connection.recv(1024)
            if len(buf) > 0:
                message = pickle.loads(buf)
                outqueue.put(message)

    def write():
        global thread_continuing
        while thread_continuing:
            data = inqueue.get() # Block until we get something
            pickled = pickle.dumps(data)
            connection.send(pickled)

    readthread = Thread(target=read)
    writethread = Thread(target=write)

    show = TennisShow(bridge(), inqueue=outqueue, outqueue=inqueue)

    readthread.start()
    writethread.start()

    try:
        show.run(framerate=40)
    finally:
        global thread_continuing
        thread_continuing = False
        connection.close()
        serversocket.close()

{'fraction_non_alphanumeric': 0.0849443468072642, 'fraction_numerical': 0.01200937316930287, 'mean_word_length': 2.773480662983425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7007163', 'n_tokens_mistral': 1032, 'n_tokens_neox': 977, 'n_words': 270}