<commit_before>
from re import match

from django.core.handlers.wsgi import WSGIHandler
from django.core.management.base import BaseCommand
from django.core.management.commands.runserver import naiveip_re
from socketio import SocketIOServer


class Command(BaseCommand):

    def handle(self, addrport="", **kwargs):

        if not addrport:
            self.addr = "127.0.0.1"
            self.port = 9000
        else:
            m = match(naiveip_re, addrport)
            if m is None:
                raise CommandError('"%s" is not a valid port number '
                                   'or address:port pair.' % addrport)
            self.addr, _, _, _, self.port = m.groups()

        bind = (self.addr, int(self.port))
        print
        print "SocketIOServer running on %s:%s" % bind
        print
        server = SocketIOServer(bind, WSGIHandler(), resource="socket.io")
        server.serve_forever()<commit_msg>Automated merge with ssh://bitbucket.org/stephenmcd/drawnby<commit_after>
from re import match
from thread import start_new_thread
from time import sleep
from os import getpid, kill
from signal import SIGINT

from django.core.handlers.wsgi import WSGIHandler
from django.core.management.base import BaseCommand, CommandError
from django.core.management.commands.runserver import naiveip_re
from django.utils.autoreload import code_changed, restart_with_reloader
from socketio import SocketIOServer


RELOAD = False

def reload_watcher():
    global RELOAD
    while True:
        RELOAD = code_changed()
        if RELOAD:
            kill(getpid(), SIGINT)
        sleep(1)

class Command(BaseCommand):

    def handle(self, addrport="", **kwargs):

        if not addrport:
            self.addr = "127.0.0.1"
            self.port = 9000
        else:
            m = match(naiveip_re, addrport)
            if m is None:
                raise CommandError('"%s" is not a valid port number '
                                   'or address:port pair.' % addrport)
            self.addr, _, _, _, self.port = m.groups()

        start_new_thread(reload_watcher, ())
        try:
            bind = (self.addr, int(self.port))
            print
            print "SocketIOServer running on %s:%s" % bind
            print
            server = SocketIOServer(bind, WSGIHandler(), resource="socket.io")
            server.serve_forever()
        except KeyboardInterrupt:
            if RELOAD:
                print
                print "Reloading..."
                restart_with_reloader()
            else:
                raise
{'fraction_non_alphanumeric': 0.08856808427623879, 'fraction_numerical': 0.008193523214982443, 'mean_word_length': 2.078031212484994, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4324162', 'n_tokens_mistral': 739, 'n_tokens_neox': 713, 'n_words': 198}