'Launch a process to process the given file.
:param result_queue: the queue to use for passing back the result
:type result_queue: multiprocessing.Queue
:param file_path: the file to process
:type file_path: unicode
:param pickle_dags: whether to pickle the DAGs found in the file and
save them to the DB
:type pickle_dags: bool
:param dag_id_white_list: if specified, only examine DAG ID\'s that are
in this list
:type dag_id_white_list: list[unicode]
:param thread_name: the name to use for the process that is launched
:type thread_name: unicode
:param log_file: the logging output for the process should be directed
to this file
:type log_file: unicode
:return: the process that was launched
:rtype: multiprocessing.Process'

@staticmethod
def _launch_process(result_queue, file_path, pickle_dags, dag_id_white_list, thread_name, log_file):

    def helper():
        (parent_dir, _) = os.path.split(log_file)
        if (not os.path.isdir(parent_dir)):
            os.makedirs(parent_dir)
        f = open(log_file, u'a')
        original_stdout = sys.stdout
        original_stderr = sys.stderr
        sys.stdout = f
        sys.stderr = f
        try:
            log_format = settings.LOG_FORMAT_WITH_THREAD_NAME
            settings.configure_logging(log_format=log_format)
            settings.configure_orm()
            threading.current_thread().name = thread_name
            start_time = time.time()
            logging.info(u'Started    process    (PID=%s)    to    work    on    %s', os.getpid(), file_path)
            scheduler_job = SchedulerJob(dag_ids=dag_id_white_list)
            result = scheduler_job.process_file(file_path, pickle_dags)
            result_queue.put(result)
            end_time = time.time()
            logging.info(u'Processing    %s    took    %.3f    seconds', file_path, (end_time - start_time))
        except:
            logging.exception(u'Got    an    exception!    Propagating...')
            raise
        finally:
            sys.stdout = original_stdout
            sys.stderr = original_stderr
            f.close()
    p = multiprocessing.Process(target=helper, args=(), name=u'{}-Process'.format(thread_name))
    p.start()
    return p
