<commit_before>from __future__ import print_function, with_statement, division, unicode_literals

import glob
import struct
import threading

# Python 2/3 compatibility
try:
    import queue
except ImportError:
    import Queue as queue
import time
from enum import Enum

import serial


class CustomQueue(queue.Queue):
    """
    A custom queue subclass that provides a :meth:`clear` method.
    """

    def clear(self):
        """
        Clears all items from the queue.
        """

        with self.mutex:
            unfinished = self.unfinished_tasks - len(self.queue)
            if unfinished <= 0:
                if unfinished < 0:
                    raise ValueError('task_done() called too many times')
                self.all_tasks_done.notify_all()
            self.unfinished_tasks = unfinished
            self.queue.clear()
            self.not_full.notify_all()


BAUDRATE = 115200
is_connected_lock = threading.Lock()
is_connected = False
# Number of messages we can send to the Arduino without receiving a RECEIVED response
n_messages_allowed = 3
n_received_semaphore = threading.Semaphore(n_messages_allowed)
serial_lock = threading.Lock()
command_queue = CustomQueue(2)  # Must be >= 2 (motor + servo order)
rate = 1 / 1000  # 1000 Hz (limit the rate of communication with the arduino)
<commit_msg>Update rate of communication<commit_after>from __future__ import print_function, with_statement, division, unicode_literals

import glob
import struct
import threading

# Python 2/3 compatibility
try:
    import queue
except ImportError:
    import Queue as queue
import time
from enum import Enum

import serial


class CustomQueue(queue.Queue):
    """
    A custom queue subclass that provides a :meth:`clear` method.
    """

    def clear(self):
        """
        Clears all items from the queue.
        """

        with self.mutex:
            unfinished = self.unfinished_tasks - len(self.queue)
            if unfinished <= 0:
                if unfinished < 0:
                    raise ValueError('task_done() called too many times')
                self.all_tasks_done.notify_all()
            self.unfinished_tasks = unfinished
            self.queue.clear()
            self.not_full.notify_all()


BAUDRATE = 115200
is_connected_lock = threading.Lock()
is_connected = False
# Number of messages we can send to the Arduino without receiving a RECEIVED response
n_messages_allowed = 3
n_received_semaphore = threading.Semaphore(n_messages_allowed)
serial_lock = threading.Lock()
command_queue = CustomQueue(2)  # Must be >= 2 (motor + servo order)
rate = 1 / 2000  # 2000 Hz (limit the rate of communication with the arduino)

{'fraction_non_alphanumeric': 0.07343574372424129, 'fraction_numerical': 0.016485575121768452, 'mean_word_length': 2.869565217391304, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '778775', 'n_tokens_mistral': 798, 'n_tokens_neox': 727, 'n_words': 245}