Esempio n. 1
0
def _execute_run_command_body(recon_pipeline, pipeline_run_id, instance,
                              write_stream_fn):

    # we need to send but the fact that we have loaded the args so the calling
    # process knows it is safe to clean up the temp input file
    write_stream_fn(ExecuteRunArgsLoadComplete())

    pipeline_run = instance.get_run_by_id(pipeline_run_id)

    pid = os.getpid()
    instance.report_engine_event(
        "Started process for pipeline (pid: {pid}).".format(pid=pid),
        pipeline_run,
        EngineEventData.in_process(pid, marker_end="cli_api_subprocess_init"),
    )

    # Perform setup so that termination of the execution will unwind and report to the
    # instance correctly
    setup_windows_interrupt_support()

    try:
        for event in core_execute_run(recon_pipeline, pipeline_run, instance):
            write_stream_fn(event)
    finally:
        instance.report_engine_event(
            "Process for pipeline exited (pid: {pid}).".format(pid=pid),
            pipeline_run,
        )
"""Test a chain of child processes with compute log tails."""

import sys
import time

from dagster.serdes.ipc import interrupt_ipc_subprocess, open_ipc_subprocess
from dagster.utils import file_relative_path
from dagster.utils.interrupts import setup_windows_interrupt_support

if __name__ == "__main__":
    setup_windows_interrupt_support()
    (
        child_opened_sentinel,
        parent_interrupt_sentinel,
        child_started_sentinel,
        stdout_pids_file,
        stderr_pids_file,
        child_interrupt_sentinel,
    ) = (sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5],
         sys.argv[6])
    child_process = open_ipc_subprocess([
        sys.executable,
        file_relative_path(__file__, "compute_log_subprocess.py"),
        stdout_pids_file,
        stderr_pids_file,
        child_started_sentinel,
        child_interrupt_sentinel,
    ])
    with open(child_opened_sentinel, "w") as fd:
        fd.write("opened_ipc_subprocess")
    try: