<commit_before># coding: cp1251

import itertools, linecache, sys, time, os, imp, traceback

from os.path import abspath, basename, dirname, exists, splitext

import pony
from pony.utils import get_mtime, shortened_filename
from pony.logging import log, log_exc, ERROR, DEBUG

USE_AUTORELOAD = True

mtimes = {}
clear_funcs = []
reloading = False

def on_reload(func):
    if func not in clear_funcs: clear_funcs.append(func)
    return func

def load_main():
    name, ext = splitext(basename(pony.MAIN_FILE))
    file, filename, description = imp.find_module(name, [ pony.MAIN_DIR ])
    try: imp.load_module('__main__', file, filename, description)
    finally:
        if file: file.close()

def reload(modules, changed_module, filename):
    global reloading
    reloading = True
    success = True
    log(type='RELOAD:begin', prefix='RELOADING: ', text=shortened_filename(filename), severity=ERROR,
        module=changed_module.__name__, modules=dict((m.__name__, m.__file__) for m in modules))
    try:
        try:
            for clear_func in clear_funcs: clear_func()
            mtimes.clear()
            linecache.checkcache()
            for m in modules: sys.modules.pop(m.__name__, None)
            load_main()
        except Exception:
            success = False
            log_exc()
            raise
    finally:
        log(type='RELOAD:end', severity=DEBUG,
            text=success and 'Reloaded successfully' or 'Reloaded with errors', success=success)
        reloading = False

reloading_exception = None

def use_autoreload():
    if pony.MODE != 'CHERRYPY' or pony.mainloop_counter.next(): return
    try: load_main()
    except Exception, e:
        pony.exception_in_main = e
        raise
    global reloading_exception
    while True:
        if pony.shutdown: sys.exit()
        if not reloading_exception:
            modules = [ m for name, m in sys.modules.items()<commit_msg>Fixed bug: application do not exit immediately without http.start()<commit_after># coding: cp1251

import itertools, linecache, sys, time, os, imp, traceback

from os.path import abspath, basename, dirname, exists, splitext

import pony
from pony.utils import get_mtime, shortened_filename
from pony.logging import log, log_exc, ERROR, DEBUG

USE_AUTORELOAD = True

mtimes = {}
clear_funcs = []
reloading = False

def on_reload(func):
    if func not in clear_funcs: clear_funcs.append(func)
    return func

def load_main():
    name, ext = splitext(basename(pony.MAIN_FILE))
    file, filename, description = imp.find_module(name, [ pony.MAIN_DIR ])
    try: imp.load_module('__main__', file, filename, description)
    finally:
        if file: file.close()

def reload(modules, changed_module, filename):
    global reloading
    reloading = True
    success = True
    log(type='RELOAD:begin', prefix='RELOADING: ', text=shortened_filename(filename), severity=ERROR,
        module=changed_module.__name__, modules=dict((m.__name__, m.__file__) for m in modules))
    try:
        try:
            for clear_func in clear_funcs: clear_func()
            mtimes.clear()
            linecache.checkcache()
            for m in modules: sys.modules.pop(m.__name__, None)
            load_main()
        except Exception:
            success = False
            log_exc()
            raise
    finally:
        log(type='RELOAD:end', severity=DEBUG,
            text=success and 'Reloaded successfully' or 'Reloaded with errors', success=success)
        reloading = False

reloading_exception = None

def use_autoreload():
    if pony.MODE != 'CHERRYPY' or pony.mainloop_counter.next(): return
    try: load_main()
    except Exception, e:
        pony.exception_in_main = e
        raise
    if not pony._do_mainloop: sys.exit()
    global reloading_exception
    while True:
        if pony.shutdown: sys.exit()
        if not reloading_exception:
            modules = [ m for name, m in sys.modules.items()
{'fraction_non_alphanumeric': 0.09595316874522779, 'fraction_numerical': 0.0020361415118350726, 'mean_word_length': 2.9939024390243905, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7176665', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1181, 'n_words': 331}