<commit_before>import time
from collections import deque
from threading import Thread
from ducklingScriptParser import ducklingScriptParser
import threads

def main():
    #load all chapters and missions
    from missionList import missionList
    missionList = missionList()

    #run the menu to make a selection from the available missions
    from SpaceAlertMenu import SpaceAlertMenu
    menu = SpaceAlertMenu()
    chapter, mission = menu.main(missionList)

    if chapter == None and mission == None:
        return False
    else:
        script = missionList.getScript(chapter, mission)
        runGame(script)
        return True

def runGame(script):

    # Initilaize the audio, display, and communiquation queu:
    audioQ = deque([])
    displayQ = deque([])
    threadCommunicationQ = deque ([])

    #parse the duckling script
    eventList = ducklingScriptParser().convertScript(script)

    # Start the game NOW:
    startTime = time.time()

    # Spawn the audio thread:
    audioThread = Thread(target=threads.AudioThread, args=(audioQ,threadCommunicationQ))
    audioThread.setDaemon(True)
    audioThread.start()

    # Spawn the display thread:
    displayThread = Thread(target=threads.DisplayThread, args=(displayQ, startTime,threadCommunicationQ))
    displayThread.setDaemon(True)
    displayThread.start()

    for timeEvent, event in eventList:
        # Set the timer for the next event.
        timer = startTime + timeEvent

        # Wait for next event.
        while time.time() < timer:
            # go easy on the CPU:
            time.sleep(.1)

        # Add the que's to the event and run the event
        event.setQs(audioQ, displayQ)
        event.execute()

    #Signal the Thread to end, and wait for it.
    threadCommunicationQ.append('AUDIO-STOP')
    threadCommunicationQ.append('DISPLAY-STOP')
    audioThread.join()
    displayThread.join()

if __name__ == "__main__":
    #play the main until it quits
    play = True
    while play:<commit_msg>adds a waiting time to the killing of the queues to allow last messages to be displayed that are in callbacks<commit_after>import time
from collections import deque
from threading import Thread
from ducklingScriptParser import ducklingScriptParser
import threads

def main():
    #load all chapters and missions
    from missionList import missionList
    missionList = missionList()

    #run the menu to make a selection from the available missions
    from SpaceAlertMenu import SpaceAlertMenu
    menu = SpaceAlertMenu()
    chapter, mission = menu.main(missionList)

    if chapter == None and mission == None:
        return False
    else:
        script = missionList.getScript(chapter, mission)
        runGame(script)
        return True

def runGame(script):

    # Initilaize the audio, display, and communiquation queu:
    audioQ = deque([])
    displayQ = deque([])
    threadCommunicationQ = deque ([])

    #parse the duckling script
    eventList = ducklingScriptParser().convertScript(script)

    # Start the game NOW:
    startTime = time.time()

    # Spawn the audio thread:
    audioThread = Thread(target=threads.AudioThread, args=(audioQ,threadCommunicationQ))
    audioThread.setDaemon(True)
    audioThread.start()

    # Spawn the display thread:
    displayThread = Thread(target=threads.DisplayThread, args=(displayQ, startTime,threadCommunicationQ))
    displayThread.setDaemon(True)
    displayThread.start()

    for timeEvent, event in eventList:
        # Set the timer for the next event.
        timer = startTime + timeEvent

        # Wait for next event.
        while time.time() < timer:
            # go easy on the CPU:
            time.sleep(.1)

        # Add the que's to the event and run the event
        event.setQs(audioQ, displayQ)
        event.execute()

    #Give the mp3s 15 seconds to finish playing
    time.sleep(20)

    #Signal the Thread to end, and wait for it.
    threadCommunicationQ.append('AUDIO-STOP')
    threadCommunicationQ.append('DISPLAY-STOP')
    audioThread.join()
    displayThread.join()

if __name__ == "__main__":
    #play the main until it quits
    play = True
    while play:
{'fraction_non_alphanumeric': 0.07836538461538461, 'fraction_numerical': 0.0016826923076923078, 'mean_word_length': 3.087426326129666, 'pattern_counts': {'":': 2, '<': 5, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1733377', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1128, 'n_words': 382}