<commit_before>"""Master Client implementation."""
import time
import paho.mqtt.client as mqtt
from datetime import datetime
from .messages import *


def start_master():
    """Start MQTT client with setup that makes it a master."""
    client = mqtt.Client()
    client.connect("localhost", 1883, keepalive=60)
    client.subscribe("printouts")
    return client


def publish_cmd(client, message, delay=.2):
    """Convenience wrapper around MQTT's publish method.

    :message: should be one of the types defined in messages.py
    """
    client.publish(topic="commands", payload=repr(message) + ";" + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S,%f')[:-3])
    # If we chain multiple publish commands, we need delays between them
    time.sleep(delay)


if __name__ == '__main__':
    from messages import *
    m = start_master()
    publish_cmd(m, ShowAttrMessage("test", "max_speed"))<commit_msg>Set delay to 0<commit_after>"""Master Client implementation."""
import time
import paho.mqtt.client as mqtt
from datetime import datetime
from .messages import *


def start_master():
    """Start MQTT client with setup that makes it a master."""
    client = mqtt.Client()
    client.connect("localhost", 1883, keepalive=60)
    client.subscribe("printouts")
    return client


def publish_cmd(client, message, delay=0):
    """Convenience wrapper around MQTT's publish method.

    :message: should be one of the types defined in messages.py
    """
    client.publish(topic="commands", payload=repr(message) + ";" + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S,%f')[:-3])
    # If we chain multiple publish commands, we need delays between them
    time.sleep(delay)


if __name__ == '__main__':
    from messages import *
    m = start_master()
    publish_cmd(m, ShowAttrMessage("test", "max_speed"))
{'fraction_non_alphanumeric': 0.13395810363836824, 'fraction_numerical': 0.009371554575523704, 'mean_word_length': 4.200573065902579, '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': '4715610', 'n_tokens_mistral': 568, 'n_tokens_neox': 541, 'n_words': 168}