<commit_before>import logging
import time

from ppb.utilities import Queue, Publisher
import ppb.event as event

publisher = Publisher()
event_queue = Queue()
scenes = []
last_tick = time.time()
running = True


def run(first_scene):
    scenes.append(first_scene)
    publisher.subscribe(event.Tick, "engine", tick)
    publisher.subscribe(event.Quit, "engine", game_quit)
    publisher.subscribe(event.PushScene, "engine", push)
    publisher.subscribe(event.PopScene, "engine", pop)
    publisher.subscribe(event.ReplaceScene, "engine", replace)
    while running:
        try:
            cur_event = event_queue.pop()
            publisher.publish(cur_event)
            scenes[-1].publish(cur_event)
        except IndexError:
            tick()
    return 0


def tick(*_):
    global last_tick

    current_tick = time.time()
    value = current_tick - last_tick
    logging.debug("Current time delta: {}".format(value))
    event_queue.push(event.Tick(value))
    last_tick = current_tick


def game_quit(*_):
    global running
    running = False


def push(e):
    scenes.append(e.scene)


def pop(*_):
    scenes.pop()


def replace(e):
    scenes.pop()
    scenes.append(e.scene)
<commit_msg>Close 5: Fix overly broad exception case.<commit_after>import logging
import time

from ppb.utilities import Queue, Publisher
import ppb.event as event

publisher = Publisher()
event_queue = Queue()
scenes = []
last_tick = time.time()
running = True


def run(first_scene):
    scenes.append(first_scene)
    publisher.subscribe(event.Tick, "engine", tick)
    publisher.subscribe(event.Quit, "engine", game_quit)
    publisher.subscribe(event.PushScene, "engine", push)
    publisher.subscribe(event.PopScene, "engine", pop)
    publisher.subscribe(event.ReplaceScene, "engine", replace)
    while running:
        try:
            cur_event = event_queue.pop()
        except IndexError:
            tick()
        publisher.publish(cur_event)
        scenes[-1].publish(cur_event)
    return 0


def tick(*_):
    global last_tick

    current_tick = time.time()
    value = current_tick - last_tick
    logging.debug("Current time delta: {}".format(value))
    event_queue.push(event.Tick(value))
    last_tick = current_tick


def game_quit(*_):
    global running
    running = False


def push(e):
    scenes.append(e.scene)


def pop(*_):
    scenes.pop()


def replace(e):
    scenes.pop()
    scenes.append(e.scene)

{'fraction_non_alphanumeric': 0.11677631578947369, 'fraction_numerical': 0.002055921052631579, 'mean_word_length': 3.268421052631579, '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': '5157019', 'n_tokens_mistral': 772, 'n_tokens_neox': 773, 'n_words': 174}