<commit_before>import threading
import time
import math
from Queue import Queue

class ControlThread(object):

    def __init__(self, delay=0):
        self.delay = delay
        self.queue = Queue()
        self.sleep = threading.Condition()

    def start(self, sense, rules, robot):
        self.sense = sense
        self.rules = rules
        self.robot = robot
        sense.start(self, robot)
        thread = threading.Thread(target=self.run, args=())
        thread.daemon = True                            # Daemonize thread
        thread.start()                                  # Start the execution

    def operation(self, operation, args, delay_s=None):
        if delay_s is None:
            delay_s = self.delay / 1000.0
        self.queue.put({
            'operation': operation,
            'timestamp': time.time() + delay_s,
            'args': args
        })
<commit_msg>Missing import that was throwing error when queue is already empty.<commit_after>import threading
import time
import math
from Queue import Queue, Empty

class ControlThread(object):

    def __init__(self, delay=0):
        self.delay = delay
        self.queue = Queue()
        self.sleep = threading.Condition()

    def start(self, sense, rules, robot):
        self.sense = sense
        self.rules = rules
        self.robot = robot
        sense.start(self, robot)
        thread = threading.Thread(target=self.run, args=())
        thread.daemon = True                            # Daemonize thread
        thread.start()                                  # Start the execution

    def operation(self, operation, args, delay_s=None):
        if delay_s is None:
            delay_s = self.delay / 1000.0
        self.queue.put({
            'operation': operation,
            'timestamp': time.time() + delay_s,
            'args': args
        })

{'fraction_non_alphanumeric': 0.09595687331536389, 'fraction_numerical': 0.00646900269541779, 'mean_word_length': 1.799396681749623, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5673787', 'n_tokens_mistral': 510, 'n_tokens_neox': 492, 'n_words': 141}