<commit_before>import os
import subprocess
import atexit
import signal

from django.contrib.staticfiles.management.commands.runserver import Command\
    as StaticfilesRunserverCommand


class Command(StaticfilesRunserverCommand):
    def inner_run(self, *args, **options):
        self.start_gulp()

        return super(Command, self).inner_run(*args, **options)

    def start_gulp(self):
        self.stdout.write('>>> Starting gulp')

        self.gulp_process = subprocess.Popen(
            ['gulp'],
            shell=True,
            stdin=subprocess.PIPE,
            stdout=self.stdout,
            stderr=self.stderr,
        )

        self.stdout.write('>>> gulp process on pid {0}'
                          .format(self.gulp_process.pid))

        def kill_gulp_process(pid):
            self.stdout.write('>>> Closing gulp process')
            os.kill(pid, signal.SIGTERM)

        atexit.register(kill_gulp_process, self.gulp_process.pid)<commit_msg>Do something useful if gulp fails<commit_after>import atexit
import subprocess

from django.contrib.staticfiles.management.commands.runserver import Command \
    as StaticfilesRunserverCommand
from django.core.management.base import CommandError


class Command(StaticfilesRunserverCommand):
    def inner_run(self, *args, **options):
        self.start_gulp()

        return super(Command, self).inner_run(*args, **options)

    def start_gulp(self):
        self.stdout.write('>>> Starting gulp')

        gulp_process = subprocess.Popen(
            ['gulp'],
            shell=True,
            stdin=subprocess.PIPE,
            stdout=self.stdout,
            stderr=self.stderr)

        if gulp_process.poll() is not None:
            raise CommandError('gulp failed to start')

        self.stdout.write('>>> gulp process on pid {0}'
                          .format(gulp_process.pid))

        def kill_gulp_process(gulp_process):
            self.stdout.write('>>> Closing gulp process')

            gulp_process.terminate()

        atexit.register(kill_gulp_process, gulp_process)
{'fraction_non_alphanumeric': 0.10353168843734882, 'fraction_numerical': 0.0009675858732462506, 'mean_word_length': 2.5532646048109964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '1074818', 'n_tokens_mistral': 607, 'n_tokens_neox': 579, 'n_words': 121}