<commit_before>#!/usr/bin/env python
import thread
import rospy

import os
import subprocess
import signal

import service
import architecture

def trace():
    rospy.init_node('rostrace')

    # setup service re-direction
    # blocks until all services are redirected
    services = ['/hello_world']
    service.tap_services(services)

    # setup architecture monitoring
    try:
        thread.start_new_thread(architecture.record, ())

        # use semaphore to communicate status of architecture
        # log to bag file
        p_recorder = subprocess.Popen("rosbag record -a", preexec_fn=os.setsid, shell=True)
        print("Recording to rosbag...")
        thread.start_new_thread(p_recorder.communicate, ())

        # spin!
        rospy.spin()

    # safely stop recording
    finally:
        os.killpg(p_recorder.pid, signal.SIGINT)


def main():
    trace()
<commit_msg>fixed rostrace to start bag recording before monitoring<commit_after>#!/usr/bin/env python
import thread
import rospy

import os
import subprocess
import signal

import service
import architecture

def trace():
    rospy.init_node('rostrace')
    try:
        # use semaphore to communicate status of architecture
        # log to bag file
        p_recorder = subprocess.Popen("rosbag record -a", preexec_fn=os.setsid, shell=True)
        print("Recording to rosbag...")
        thread.start_new_thread(p_recorder.communicate, ())

        # architecture monitoring
        thread.start_new_thread(architecture.record, ())

        # setup service re-direction
        # blocks until all services are redirected
        services = ['/hello_world']
        service.tap_services(services)

        # spin!
        rospy.spin()

    # safely stop recording
    finally:
        os.killpg(p_recorder.pid, signal.SIGINT)


def main():
    trace()

{'fraction_non_alphanumeric': 0.0906608410704533, 'fraction_numerical': 0.0, 'mean_word_length': 2.8978723404255318, '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': '5791053', 'n_tokens_mistral': 554, 'n_tokens_neox': 534, 'n_words': 142}